Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #73654
| Newsgroups | comp.lang.python |
|---|---|
| Date | 2014-06-27 05:09 -0700 |
| Message-ID | <c2ff3090-5673-4053-bdd7-b7cb434c9421@googlegroups.com> (permalink) |
| Subject | Contouring a 2D histogram |
| From | Jamie Mitchell <jamiemitchell1604@gmail.com> |
Hi all,
I have plotted a 2D histogram like so:
python2.7
import netCDF4
import iris
import iris.palette
import numpy as np
import matplotlib as mpl
import matplotlib.cm as cm
import matplotlib.mlab as mlab
import matplotlib.pyplot as plt
from matplotlib.colors import from_levels_and_colors
fig=plt.figure()
nbins=20
nice_cmap=plt.get_cmap('brewer_RdYlBu_11')
colors=nice_cmap([5,6,7,8,9,10])
levels=[1,2,3,4,5]
cmap, norm=from_levels_and_colors(levels, colors, extend='both')
H, xedges, yedges=np.histogram2d(te_Q0_con_sw,hs_Q0_con_sw,bins=nbins)
Hmasked=np.ma.masked_where(H==0,H)
plt.pcolormesh(xedges,yedges,Hmasked,cmap=cmap,norm=norm,label='Q0 control')
# From this I get a 'scattered' 2D histogram.
Does anyone know how I can contour that scatter?
Thanks,
Jamie
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
Contouring a 2D histogram Jamie Mitchell <jamiemitchell1604@gmail.com> - 2014-06-27 05:09 -0700 Re: Contouring a 2D histogram Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-06-27 16:59 +0100
csiph-web