On 01/25/2011 08:51 PM, Paul Ivanov wrote: > Eric Firing, on 2011-01-25 19:52, wrote: >> On 01/25/2011 06:58 PM, Shrividya Ravi wrote: >> [...] >>> On the same topic of the colorbar, how can I readjust the colors such >>> that it only goes between user-specified values? For example, I have one >>> imshow plot where the values range between 0 and 350. However, I only >>> want to look at the values between 300 and 350. >> >> z = np.arange(25) >> z.shape = 5,5 >> imshow(z, vmin=10, vmax=20, interpolation='nearest') >> colorbar(extend='both') >> >> Does that give the desired result? > > Hi Shrividya, > > Here's how I interpreted what was being asked, in case that > helps.
(Your interpretation seems like a very strange thing to want to do, but maybe you are right. The OP can inform us.) > > Also, Eric, is there a reason we make an outline instead of > just cbar.ax.set_frame_on? - My manual adjustments screw up and > confuse whatever data cbar.outline depends on Yes, we need to make our own outline because a colorbar does not have to be a rectangle; it can be pointed at either end or both ends. Eric > > x = np.random.rand(100) > y = np.random.rand(100) > z = np.random.rand(100) > collection = plt.scatter(x, y, c=z*350, vmin=0, vmax=350) > cbar = plt.colorbar() > cbar.ax.set_ylim(cbar.norm((300,350))) > cbar.ax.set_xlim(cbar.norm((300,350))) # maintain aspect ratio > cbar.set_ticks(np.linspace(300,350,6)) > # didn't see a quick way to fix the outline > cbar.outline.set_visible(False) > cbar.ax.set_frame_on(True) > plt.draw() > > best, > ------------------------------------------------------------------------------ Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)! Finally, a world-class log management solution at an even better price-free! Download using promo code Free_Logger_4_Dev2Dev. Offer expires February 28th, so secure your free ArcSight Logger TODAY! http://p.sf.net/sfu/arcsight-sfd2d _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users