Eric Firing wrote:
> Phillip M. Feldman wrote:
>> Hello Eric-
>>
>> I'd like to understand the reason why you object to 
>> piecewise-constant colormaps.  I have found these to be useful for 
>> some types of plots.  
>
> It is a crude and indirect way of achieving a result that can be 
> achieved precisely and directly using ListedColormap and BoundaryNorm, 
> or possibly a subclass.  The problem is that discretization is being 
> done at the wrong stage.
>
> Suppose you have data in the range 1.5 to 2.5, and you want the low 
> third of that range to be red, the middle green, and the upper blue.  
> If you use LinearSegmentedColormap and one of your functions to make a 
> discrete map, then you will have divided your interval of length 1 
> into 256 segments, which does not allow you to specify exactly 1.5 + 
> 1.0/3 as a transition point.  You have only 8 bits of precision available.
OK.  Good explanation.
>
> What does allow you to specify the transitions exactly (to within the 
> limits of double precision) is this:
>
> cmap = ListedColormap(['r','g','b'])
> norm = BoundaryNorm([1.5+1.0/3, 1.5+2.0/3], cmap.N)
>
> Simple, readable, flexible: choose any boundaries you like, specify 
> the colors any way you like, including pulling them out of an existing 
> colormap.  Efficient: the cmap lookup table has only as many entries 
> as it needs, and the index into that table is calculated directly in a 
> single step.
>
> Now if you need autoscaling, with the boundaries calculated from vmin 
> and vmax, then this can be done by subclassing BoundaryNorm.  In both 
> cases, after using this cmap and norm for a mappable, passing that 
> mappable to colorbar will yield a reasonable result, because colorbar 
> has special code to handle the BoundaryNorm.
>
>
>> Also, the functionality to create piecewise-constant colormaps is 
>> already provided by LinearSegmentedColormap, so "the cat is already 
>> out of the bag", so to speak.. (I created my functions mainly because I 
> LinearSegmentedColormap is very general, so yes, it can be used for this.
>> found the LinearSegmentedColormap interface painful to use.  Since then, 
> That painfulness is exactly the reason why John Hunter added the 
> from_list method 8 months ago (I forgot it had been there that long), 
> and Reinier recently made it more flexible.

When I look at the online documentaiton for from_list, here's what I 
see: "Make a linear segmented colormap with /name/ from a sequence of 
/colors/ which evenly transitions from colors[0] at val=1 to colors[-1] 
at val=1. N is the number of rgb quantization levels."  There must be a 
mistake here, because val=l at both ends.  Also, is there web 
documentation for Reinier's new version?

Thanks!

Phillip

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel

Reply via email to