Skip to content

Instantly share code, notes, and snippets.

@cpelley
Created February 6, 2015 17:12
Show Gist options
  • Save cpelley/509c5cad5ad9ecccff79 to your computer and use it in GitHub Desktop.
Save cpelley/509c5cad5ad9ecccff79 to your computer and use it in GitHub Desktop.
Quick visualisation
def plot_data(*args, **kwargs):
save = kwargs.pop('save', False)
import matplotlib.pyplot as plt
import iris.plot as iplt
markers = ('+', 'x', 's')
if save is True:
plt.switch_backend('Agg')
else:
plt.switch_backend('TkAgg')
plt.figure(figsize=(6*len(args), 6))
for ind, source in enumerate(args):
#plt.subplot(1, len(args), ind)
print source
iplt.points(source, marker=markers[ind], s=60)
ax = plt.gca()
#xcoord = source.coord(axis='x')
#xpnts = xcoord.bounds if xcoord.has_bounds() else xcoord.points
#ax.set_xlim(xpnts.min(), xpnts.max())
ax.coastlines()
#plt.colorbar()
if save:
import time
fnme = 'image.{}.png'.format(time.time())
print 'Printing to file: {}'.format(fnme)
plt.savefig(fnme)
else:
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment