Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #73654 > unrolled thread
| Started by | Jamie Mitchell <jamiemitchell1604@gmail.com> |
|---|---|
| First post | 2014-06-27 05:09 -0700 |
| Last post | 2014-06-27 16:59 +0100 |
| Articles | 2 — 2 participants |
Back to article view | Back to comp.lang.python
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
| From | Jamie Mitchell <jamiemitchell1604@gmail.com> |
|---|---|
| Date | 2014-06-27 05:09 -0700 |
| Subject | Contouring a 2D histogram |
| Message-ID | <c2ff3090-5673-4053-bdd7-b7cb434c9421@googlegroups.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
[toc] | [next] | [standalone]
| From | Mark Lawrence <breamoreboy@yahoo.co.uk> |
|---|---|
| Date | 2014-06-27 16:59 +0100 |
| Message-ID | <mailman.11287.1403884804.18130.python-list@python.org> |
| In reply to | #73654 |
On 27/06/2014 13:09, Jamie Mitchell wrote:
> 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
>
You're more likely to get answers from
https://lists.sourceforge.net/lists/listinfo/matplotlib-users or, if you
prefer the one stop shop, gmane.comp.python.matplotlib.general
--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.
Mark Lawrence
---
This email is free from viruses and malware because avast! Antivirus protection is active.
http://www.avast.com
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web