Dear folks,

I tried to plot a colored map with non-uniformed discrete colorbar and 
found a few threads related with this. However, I could not find a way 
to apply non-uniformed discrete colorbar over imshow or pcolor. Would 
anybody give me a clue? Thanks in advance.

Kim


Eric Firing wrote:
> James Boyle wrote:
>> I wish to make a color filled plot with the colors defined for  
>> discrete, non-uniform intervals. Something like:
>> 0.0 -0.001  0.001-0.05   0.05-0.2     0.2-0.4      0.4-0.8      0.8-1.0
>>     red              blue             green       magenta      
>> yellow        cyan
>>
>> with the colorbar labeled appropriately.
>> I have seen discussions and solutions for discrete colors but not 
>> for  non-uniform intervals + discrete.
>> The last post I saw regarding this type of issue was august 2005 -  
>> and a solution was not resolved at that time.
>> However, Eric has done a huge amount of work in the intervening time  
>> and a smarter person than myself might have a solution now.
>>
>> Note that I do not wish just to make contours - although that would  
>> be good - but to have a general mapping code that joins allows the  
>> color rmapping to be passed to colorbar.
>> maybe some sub-class of scalarMappable that could work.
>
> This is very easy for contourf, and is illustrated in the second 
> figure made by examples/contourf_demo.py.  For your case above, it 
> would be something like
>
> levs = [0, 0.001, 0.05, 0.2, 0.4, 0.8, 1]
> colors = ['r', 'b', 'g', 'm', 'y', 'c']
> contourf(z, levs, colors=colors)
> colorbar()
>
> Unfortunately, although it *should* be just as easy for imshow or 
> pcolor, it is not at present; it can be done, probably in several 
> ways, but not in such a transparent way.  Attached is a quick attempt 
> at something that might be close to what you need.  The right way to 
> do this is to make some changes and additions to colors.py and 
> colorbar.py; I might get to that in a few days, or, more likely, it 
> might be a few weeks.
>
> Eric
>
>>
>> Thanks for any help.
>>
>> --Jim
> ------------------------------------------------------------------------
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by DB2 Express
> Download DB2 Express C - the FREE version of DB2 express and take
> control of your XML. No limits. Just data. Click to get it now.
> http://sourceforge.net/powerbar/db2/
> ------------------------------------------------------------------------
>
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to