Skip to content

Instantly share code, notes, and snippets.

View joferkington's full-sized avatar
🏠
Working from home

Joe Kington joferkington

🏠
Working from home
View GitHub Profile
#!/usr/bin/env python
"""
# Copyright 2019 Planet Labs, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
@joferkington
joferkington / download_mosaic_assets.py
Last active August 11, 2023 15:54
Download provenance or UDM data for a Planet mosaic
#! /usr/bin/env python3
# Copyright 2023 Planet Labs, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
@joferkington
joferkington / arrowed_spines.py
Created October 6, 2012 18:15
Arrows on the ends of spines for matplotlib
import matplotlib.pyplot as plt
def arrowed_spines(ax=None, arrow_length=20, labels=('', ''), arrowprops=None):
xlabel, ylabel = labels
if ax is None:
ax = plt.gca()
if arrowprops is None:
arrowprops = dict(arrowstyle='<|-', facecolor='black')
for i, spine in enumerate(['left', 'bottom']):
@joferkington
joferkington / yo_dawg.py
Created February 21, 2014 17:15
I'm having a bit too much fun with this...
import matplotlib.pyplot as plt
import numpy as np
def main():
t = np.linspace(0, 4*np.pi, 1000)
fig, ax = plt.subplots()
ax.plot(t, np.cos(t))
ax.plot(t, np.sin(t))
inception(inception(inception(fig)))
import sys
import h5py
def main():
data = read()
if sys.argv[1] == 'x':
x_slice(data)
elif sys.argv[1] == 'z':
z_slice(data)
@joferkington
joferkington / data.csv
Last active March 20, 2021 11:37
Example of distributing a stand-alone executable with matplotlib and cx_freeze
931 Oxfordshire 9314125 123255 Larkmead School Abingdon 125 124 20 SUPP 8
931 Oxfordshire 9314126 123256 John Mason School Abingdon 164 164 25 6 16
931 Oxfordshire 9314127 123257 Fitzharrys School Abingdon 150 149 9 0 11
931 Oxfordshire 9316076 123298 Our Lady's Abingdon Abingdon 57 57 SUPP SUPP 16
@joferkington
joferkington / projection.py
Created December 27, 2014 07:32
Spießbürger's stereonet: Fixed coordinate conversions. See http://stackoverflow.com/questions/27622007
import matplotlib
from matplotlib.axes import Axes
from matplotlib.patches import Circle
from matplotlib.path import Path
from matplotlib.ticker import NullLocator, Formatter, FixedLocator
from matplotlib.transforms import Affine2D, BboxTransformTo, Transform
from matplotlib.projections import register_projection
import matplotlib.spines as mspines
import matplotlib.axis as maxis
import matplotlib.pyplot as plt
@joferkington
joferkington / mpl_contour_clipping_example.py
Last active December 10, 2020 23:10
Using a masked array for contour clipping
# There are two ways to clip data to irregular boundaries.
# One uses a masked array (and is most useful for "real" data)
# The other uses set_clip_path (and is most useful for graphics)
# This demonstrates the first (masked array)
import matplotlib.pyplot as plt
import scipy.ndimage
import numpy as np
import skimage.draw
@joferkington
joferkington / point_drag_add_delete.py
Created March 26, 2015 13:46
General example of the type of framework you need to efficiently implement drawable/draggable/deleteable artists in matplotlib.
import numpy as np
import matplotlib.pyplot as plt
class DrawDragPoints(object):
"""
Demonstrates a basic example of the "scaffolding" you need to efficiently
blit drawable/draggable/deleteable artists on top of a background.
"""
def __init__(self):
self.fig, self.ax = self.setup_axes()
@joferkington
joferkington / mold_spores.py
Created February 24, 2020 16:43
Some auto-generated mold-like art in matplotlib.
"""
Silly auto-generated art. Meant to look like some sort of mold spores.
Deliberately slow to render -- meant to look good at high-res.
"""
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.colors as mcolors
from matplotlib.collections import LineCollection