Revision: 4572
          http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4572&view=rev
Author:   jdh2358
Date:     2007-12-03 19:18:39 -0800 (Mon, 03 Dec 2007)

Log Message:
-----------
colormapped histogram

Added Paths:
-----------
    trunk/matplotlib/examples/hist_colormapped.py

Added: trunk/matplotlib/examples/hist_colormapped.py
===================================================================
--- trunk/matplotlib/examples/hist_colormapped.py                               
(rev 0)
+++ trunk/matplotlib/examples/hist_colormapped.py       2007-12-04 03:18:39 UTC 
(rev 4572)
@@ -0,0 +1,24 @@
+import numpy as n
+from pylab import figure, show
+import matplotlib.cm as cm
+import matplotlib.colors as colors
+
+fig = figure()
+ax = fig.add_subplot(111)
+Ntotal = 1000
+N, bins, patches = ax.hist(n.random.rand(Ntotal), 20)
+
+#I'll color code by height, but you could use any scalar
+
+
+# we need to normalize the data to 0..1 for the full
+# range of the colormap
+fracs = N.astype(float)/N.max()
+norm = colors.normalize(fracs.min(), fracs.max())
+
+for thisfrac, thispatch in zip(fracs, patches):
+    color = cm.jet(norm(thisfrac))
+    thispatch.set_facecolor(color)
+
+
+show()


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell.  From the desktop to the data center, Linux is going
mainstream.  Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
_______________________________________________
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins

Reply via email to