This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import scipy.sparse | |
import scipy.ndimage | |
import scipy.stats | |
import scipy.signal | |
import matplotlib.pyplot as plt | |
def main(): | |
x, y = generate_data(int(1e7)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /bin/sh | |
# Setup | |
datfile=$(mktemp) | |
echo "ElapsedTime MemUsed" > $datfile | |
starttime=$(date +%s.%N) | |
# Run the specified command in the background | |
$@ & |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Converts one or more zmap grids to ascii x,y,z tab-delimited files. Exported | |
files will be saved to the current directory with a ".xyz" extension and the | |
same file name as the original. Null grid values will not be included unless | |
the "--with_nulls" option is specified. | |
Usage: | |
zmap2xyz.py [options] INPUT_FILES... | |
Options: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
# https://mtgjson.com/v4/json/AllCards.json.zip | |
with open('AllCards.json', 'r') as infile: | |
data = json.load(infile) | |
for name in data: | |
card = data[name] | |
cost = card.get('manaCost', '') | |
if cost.count('{') > 6: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from matplotlib import cbook | |
class DataCursor(object): | |
"""A simple data cursor widget that displays the x,y location of a | |
matplotlib artist when it is selected.""" | |
def __init__(self, artists, tolerance=5, offsets=(-20, 20), | |
template='x: %0.2f\ny: %0.2f', display_all=False): | |
"""Create the data cursor and connect it to the relevant figure. | |
*artists* is the matplotlib artist or sequence of artists that will be | |
selected. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import itertools | |
import matplotlib.pyplot as plt | |
from matplotlib.patches import Rectangle | |
from matplotlib.collections import PatchCollection | |
import numpy as np | |
np.random.seed(1977) | |
def main(): | |
azi = np.random.normal(20, 40, 1000) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from scipy.interpolate import Rbf | |
import matplotlib.pyplot as plt | |
from matplotlib.colors import LinearSegmentedColormap | |
from mpl_toolkits.axes_grid1 import inset_locator | |
from matplotlib.projections.polar import PolarAxes | |
np.random.seed(1977) | |
def main(): | |
x, y, z = generate_surface() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Tkinter as tk | |
import numpy as np | |
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg | |
from matplotlib.figure import Figure | |
def main(): | |
root = tk.Tk() | |
app = Application(root) | |
tk.mainloop() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib.pyplot as plt | |
from matplotlib.widgets import MultiCursor | |
import numpy as np | |
class SynchedMultiCursor(MultiCursor): | |
def __init__(self, *args, **kwargs): | |
self._enabled = True | |
MultiCursor.__init__(self, *args, **kwargs) | |
def onmove(self, event): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import matplotlib.pyplot as plt | |
from matplotlib.colors import ListedColormap | |
num = 100000 | |
x, y = np.random.random((2, num)) | |
category = np.random.randint(1, 5, num) | |
# Using multiple "plot" calls | |
fig, ax = plt.subplots() |