Useful tip from the late creator of matplotlib, John Hunter.
http://matplotlib.1069221.n5.nabble.com/dynamically-add-subplots-to-figure-td23571.html
import matplotlib.pyplot as plt
# start with one
fig = plt.figure()
ax = fig.add_subplot(111)| import json | |
| from urllib.parse import urljoin | |
| import logging | |
| import requests | |
| log = logging.getLogger(__name__) | |
| log.setLevel(logging.DEBUG) | |
| #!/usr/bin/env python | |
| # Command Repeater | |
| # | |
| # For a directory tree like: | |
| # | |
| # MainProject/ | |
| # ├── project-one | |
| # ├── project-two | |
| # ├── project-three | |
| # └── rep # This script |
| """ | |
| Environment variable context manager | |
| ------------------------------------ | |
| Support utility for managing environments in which e.g. git is run | |
| """ | |
| import os | |
| from contextlib import contextmanager | |
| from functools import wraps |
| import sys | |
| import threading | |
| import time | |
| class cSpinner(threading.Thread): | |
| """ | |
| Print things to one line dynamically | |
| """ | |
| chars = ["\\","|","/","-"] | |
| index = 0 |
| #! /bin/sh | |
| parallel -j 6 jpg2pdf -- *.JPG | |
| gs -sDEVICE=pdfwrite -dNOPAUSE -dBATCH -dSAFER -sOutputFile=combined.pdf `ls -1 *.pdf` | |
| mv combined.pdf combined.pdf.bak | |
| rm *.pdf | |
| foo="`basename "$PWD"`" |
Useful tip from the late creator of matplotlib, John Hunter.
http://matplotlib.1069221.n5.nabble.com/dynamically-add-subplots-to-figure-td23571.html
import matplotlib.pyplot as plt
# start with one
fig = plt.figure()
ax = fig.add_subplot(111)| #!/bin/sh | |
| # Run a command with stdout and stderr redirected to null | |
| # Usage: | |
| # $ quiet foo | |
| # Check command is valid | |
| command -v $1 >/dev/null 2>&1 || { echo >&2 "$1: command not found"; exit 1; } | |
| # Run command with all arguments | |
| $@ >/dev/null 2>&1 |
| def build_subparser(subparsers): | |
| """ | |
| Build subparser for this command | |
| """ | |
| parser = subparsers.add_parser('bar', help='foo help') | |
| parser.add_argument('b', type=int, help='b help') | |
| parser.set_defaults(func=main) | |
| def main(args): |
| def mjd_join(mjd1, mjd2, tol=0.0001): | |
| """ | |
| Return indices of rows in mjd1 and mjd2 matching within tol | |
| """ | |
| diff = abs(mjd1 - mjd2[:, np.newaxis]) | |
| match = diff < tol | |
| idx1 = np.mgrid[:len(mjd1), :len(mjd2)][0].T[match] | |
| idx2 = np.mgrid[:len(mjd1), :len(mjd2)][1].T[match] | |
| return idx1, idx2 |
| import numpy as np | |
| from matplotlib import pyplot as plt | |
| class MultiPlotSelector: | |
| def __init__(self, data, fig, ax): | |
| """ | |
| data in paired columns per subplot, i.e. M x (2 x N) | |
| len(ax) == M |