Re: [Matplotlib-users] Making a data-driven colormap

2010-03-30 Thread Friedrich Romstedt
2010/3/30 Ariel Rokem aro...@berkeley.edu: I ended up with the code below, using Chloe's previously posted 'subcolormap' and, in order to make the colorbar nicely attached to the main imshow plot, I use make_axes_locatable in order to generate the colorbar axes. I tried it out with a couple of

Re: [Matplotlib-users] Making a data-driven colormap

2010-03-30 Thread Ariel Rokem
Hi Friedrich, Thanks a lot - very nice! Cheers - Ariel On Tue, Mar 30, 2010 at 6:52 AM, Friedrich Romstedt friedrichromst...@gmail.com wrote: 2010/3/30 Ariel Rokem aro...@berkeley.edu: I ended up with the code below, using Chloe's previously posted 'subcolormap' and, in order to make the

Re: [Matplotlib-users] Making a data-driven colormap

2010-03-30 Thread Chloe Lewis
But this example doesn't solve the problem I was thinking of: it shows lots of colors in the colorbar that aren't used in the plot. C On Mar 30, 2010, at 6:52 AM, Friedrich Romstedt wrote: 2010/3/30 Ariel Rokem aro...@berkeley.edu: I ended up with the code below, using Chloe's previously

Re: [Matplotlib-users] Making a data-driven colormap

2010-03-30 Thread Ryan May
On Tue, Mar 30, 2010 at 11:15 AM, Chloe Lewis chle...@berkeley.edu wrote: But this example doesn't solve the problem I was thinking of: it shows lots of colors in the colorbar that aren't used in the plot. Here's a patch (and example) that I've cooked up that adds a colorbar.set_limits()

Re: [Matplotlib-users] Making a data-driven colormap

2010-03-30 Thread Friedrich Romstedt
2010/3/30 Chloe Lewis chle...@berkeley.edu: But this example doesn't solve the problem I was thinking of: it shows lots of colors in the colorbar that aren't used in the plot. I'm so stupid! Here is the correct code. I just interchanged -bounds, bound with min_val, max_val on line 28. The

Re: [Matplotlib-users] Making a data-driven colormap

2010-03-29 Thread Atomfried
I once had a similar issue. I solved it like this. It takes the minimum and maximum of the data and returns a colormap: Zero: White, Positive values: blue, Negative values: red. def mxcmap(_min,_max): if _min = 0 and _max = 0: cdict = {'red': ((0.0, 1.0, 1.0),

Re: [Matplotlib-users] Making a data-driven colormap

2010-03-29 Thread Friedrich Romstedt
2010/3/29 Friedrich Romstedt friedrichromst...@gmail.com: Note that the ticking is a bit weird, there is also a bug in matplotlib I will report on right after this e-mail, whose bugfix you will maybe want to apply to get ticking properly working.  When you have insane values for C.min() and

Re: [Matplotlib-users] Making a data-driven colormap

2010-03-29 Thread Ariel Rokem
Hi - I ended up with the code below, using Chloe's previously posted 'subcolormap' and, in order to make the colorbar nicely attached to the main imshow plot, I use make_axes_locatable in order to generate the colorbar axes. I tried it out with a couple of use-cases and it seems to do what it is

Re: [Matplotlib-users] Making a data-driven colormap

2010-03-28 Thread Chloe Lewis
To zoom in on the relevant section of a colorbar -- I convinced myself once that I'd need an auxiliary function to define a new cdict that covers only the current section of the original cdict. (and then define a new colorbar from the cdict, and maybe do a little norming of the data).

Re: [Matplotlib-users] Making a data-driven colormap

2010-03-28 Thread Chloe Lewis
Like so, not that it couldn't be improved: import matplotlib.cm as cm import matplotlib.colors as colors import pylab as p def rgb_to_dict(value, cbar): return dict(zip(('red','green','blue','alpha'), cbar(value))) def subcolorbar(xmin, xmax, cbar): '''Returns the part of cbar between

Re: [Matplotlib-users] Making a data-driven colormap

2010-03-28 Thread Ariel Rokem
Hi Chloe, _segmentdata - that's what I was looking for! Thanks a lot also for that bit of code! Cheers - Ariel On Sun, Mar 28, 2010 at 1:53 AM, Chloe Lewis chle...@berkeley.edu wrote: Like so, not that it couldn't be improved: import matplotlib.cm as cm import matplotlib.colors as

Re: [Matplotlib-users] Making a data-driven colormap

2010-03-28 Thread Friedrich Romstedt
2010/3/28 Chloe Lewis chle...@berkeley.edu: That would be a lot nicer, Friedrich; could you share demo code?  I can't make the set_ylim work, but I think I'm being clumsy with the object model. It seems that I cannot read the sections following after the From this: and I get this:? But anyway,

Re: [Matplotlib-users] Making a data-driven colormap

2010-03-27 Thread Brian Blais
On Mar 27, 2010, at 1:13 , Ariel Rokem wrote: In particular, I am interested in using the plt.cm.RdYlBu_r colormap. If the data has both negative and positive values, I want 0 to map to the central value of this colormap (a pale whitish yellow) and I want negative values to be in blue and

Re: [Matplotlib-users] Making a data-driven colormap

2010-03-27 Thread Ariel Rokem
Hi Brian, Thanks for the code - this is definitely in the direction of what I want to make! The RdYlBu_r colormap is one of the built-in colormaps available in matplotlib.pyplot.cm (you can see all of them here: http://www.scipy.org/Cookbook/Matplotlib/Show_colormaps). I think that using the

Re: [Matplotlib-users] Making a data-driven colormap

2010-03-27 Thread Friedrich Romstedt
2010/3/27 Ariel Rokem aro...@berkeley.edu: I am trying to make a color-map which will respond to the range of values in the data itself. That is - I want to take one of the mpl colormaps and use parts of it, depending on the range of the data. In particular, I am interested in using the

Re: [Matplotlib-users] Making a data-driven colormap

2010-03-27 Thread Ariel Rokem
Hi Friedrich, Thanks a lot for your response. I think that you are right - using the vmin/vmax args into imshow (as well as into pcolor) does seem to do what I want. Great! The only thing that remains now is to simultaneously stretch the colormap in the image itself to this range, while also

[Matplotlib-users] Making a data-driven colormap

2010-03-26 Thread Ariel Rokem
Hi everyone, I am trying to make a color-map which will respond to the range of values in the data itself. That is - I want to take one of the mpl colormaps and use parts of it, depending on the range of the data. In particular, I am interested in using the plt.cm.RdYlBu_r colormap. If the data