Revision: 6884
          http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6884&view=rev
Author:   ryanmay
Date:     2009-02-05 17:55:51 +0000 (Thu, 05 Feb 2009)

Log Message:
-----------
Add an example that displays all of the colormaps available.  This is based on 
code in the scipy.org cookbook. This should make a nice addition to the gallery.

Added Paths:
-----------
    branches/v0_98_5_maint/examples/pylab_examples/show_colormaps.py

Added: branches/v0_98_5_maint/examples/pylab_examples/show_colormaps.py
===================================================================
--- branches/v0_98_5_maint/examples/pylab_examples/show_colormaps.py            
                (rev 0)
+++ branches/v0_98_5_maint/examples/pylab_examples/show_colormaps.py    
2009-02-05 17:55:51 UTC (rev 6884)
@@ -0,0 +1,25 @@
+# This example comes from the Cookbook on www.scipy.org.  According to the
+# history, Andrew Straw did the conversion from an old page, but it is
+# unclear who the original author is.
+import numpy as np
+import matplotlib.pyplot as plt
+
+a = np.linspace(0, 1, 256).reshape(1,-1)
+a = np.vstack((a,a))
+
+# Get a list of the colormaps in matplotlib.  Ignore the ones that end with
+# '_r' because these are simply reversed versions of ones that don't end
+# with '_r'
+maps = sorted(m for m in plt.cm.datad if not m.endswith("_r"))
+nmaps = len(maps) + 1
+
+fig = plt.figure(figsize=(5,10))
+fig.subplots_adjust(top=0.99, bottom=0.01, left=0.2, right=0.99)
+for i,m in enumerate(maps):
+    ax = plt.subplot(nmaps, 1, i+1)
+    plt.axis("off")
+    plt.imshow(a, aspect='auto', cmap=plt.get_cmap(m), origin='lower')
+    pos = list(ax.get_position().bounds)
+    fig.text(pos[0] - 0.01, pos[1], m, fontsize=10, 
horizontalalignment='right')
+
+plt.show()


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

------------------------------------------------------------------------------
Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM)
software. With Adobe AIR, Ajax developers can use existing skills and code to
build responsive, highly engaging applications that combine the power of local
resources and data with the reach of the web. Download the Adobe AIR SDK and
Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com
_______________________________________________
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins

Reply via email to