Skip to content

Instantly share code, notes, and snippets.

View pelson's full-sized avatar

Phil Elson pelson

View GitHub Profile
@pelson
pelson / gist:e98e142b8a935142746b
Created April 14, 2015 08:26
um_packing performance.ipynb
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
@pelson
pelson / gist:786ce4827aa1cd40b3f6
Created February 3, 2015 09:47
Work in progress support for plotting 360-day calendars with matplotlib
from collections import namedtuple
import datetime
import matplotlib.dates as mdates
import matplotlib.pyplot as plt
import matplotlib.ticker as mticker
import matplotlib.transforms as mtransforms
import matplotlib.units as munits
import netcdftime
@pelson
pelson / r2py_example.ipynb
Created January 27, 2015 10:14
A simple r2py example using Iris
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@pelson
pelson / README.md
Last active August 29, 2015 14:10
Season's greetings from matplotlib (2014). Very simple animated snow scene. (run the source, or see the result at https://www.youtube.com/watch?v=POnAkPpe770)

If working on XKCD style plotting for matplotlib taught me anything, it is that playing with software in a way that it was not originally designed to do can lead to some excellent discoveries (bugs) and generate new ideas and generalisations - not to mention it being a lot of fun!

So, in that vein, I wanted to put together a simple Christmas e-card using matplotlib. My main aim was to re-purpose some of the familiar matplotlib functionality to generate a simple festive animation.

I decided to go for a snowy scene, with a snow-capped greeting and sprig of holly. The snow is simply a scatter plot scaled by flake size and animated to fall in a pleasing way. The text is making use of the path effects functionality extended in v1.4 to add randomised "snow" around the text (the same effect employed by XKCD as it happens). And the holly is a nice demonstration of the power of Paths and vector rendering in matplotlib.

The source can be found at https://gist.github.com/pelson/ca795a02a420a1b9bfbc, and it requires m

@pelson
pelson / iris_qplt_colorbar_control.ipynb
Created October 8, 2014 10:11
Describes how to get hold of the reference to the colorbar artists when using Iris' quickplot module.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@pelson
pelson / sample.py
Created August 31, 2014 15:41
Image manipulation using mpl for @stefanv.
"""
Example of applying text to an image for Stefan VdW.
The image is not transfomed throgh the mpl pipeline, and is instead
constrained to pixel space of the figure's resulting image.
"""
def new_figure(width, height):
"""
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@pelson
pelson / README
Last active August 29, 2015 14:05
Allows control the travis-ci machine via a text file, as a poor-man's keyboard.
Allows control the travis-ci machine via a text file, as a poor-man's keyboard.
Note: This is only a hacky example when I got frustrated by the queue time for travis-ci builds.
Run with the URL of the command file as the only argument:
python listen_and_execute.py https://gist.githubusercontent.com/pelson/a9e8b25496309fa2997d/raw/commands.txt
@pelson
pelson / us_coastal_states.ipynb
Last active July 6, 2021 12:42
Creating a shapefile representing the coastline segments of the US states.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@pelson
pelson / mask.ipynb
Created July 16, 2014 12:57
Demonstration of constructing a geometry based mask
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.