Quantcast

logarithmic scale of colorbar with ticks and custom labels

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

logarithmic scale of colorbar with ticks and custom labels

Sebastian Pająk-4
Hello

I have a contour plot with specified number of levels (isolines):

lev = array([2,3,5,7,10,13,17,21,26,32,42,62,80,100,120,140,180])

to have a log "z" axis I put:

from matplotlib import colors
contourf(x1, y1, z1, lev, norm=colors.LogNorm(lev[0],lev[len(lev)-1]))

now, to get colorbar in log scale:

from matplotlib.ticker import LogLocator, LogFormatter
l_f = LogFormatter(10, labelOnlyBase=False)
cbar = colorbar(format = l_f)

But the colorbar doesn't have all tick's labels specified in "lev"
variable. Ticks are placed correctly on the cbar, but only every
second tick has a text label (yes 2, 5, 10 ... etc). What should I do
to have ALL levels on colorbar labeled?

------------------------------------------------------------------------------
The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your
production scanning environment may not be a perfect world - but thanks to
Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700
Series Scanner you'll get full speed at 300 dpi even with all image
processing features enabled. http://p.sf.net/sfu/kodak-com
_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

logarithmic scale of colorbar with ticks and custom labels

Sebastian Pająk
Hello

I have a contour plot with specified number of levels (isolines):

lev = array([2,3,5,7,10,13,17,21,26,32,42,62,80,100,120,140,180])

to have a log "z" axis I put:

from matplotlib import colors
contourf(x1, y1, z1, lev, norm=colors.LogNorm(lev[0],lev[len(lev)-1]))

now, to get colorbar in log scale:

from matplotlib.ticker import LogLocator, LogFormatter
l_f = LogFormatter(10, labelOnlyBase=False)
cbar = colorbar(format = l_f)

But the colorbar doesn't have all tick's labels specified in "lev"
variable. Ticks are placed correctly on the cbar, but only every
second tick has a text label (yes 2, 5, 10 ... etc). What should I do
to have ALL levels on colorbar labeled?

------------------------------------------------------------------------------
The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your
production scanning environment may not be a perfect world - but thanks to
Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700
Series Scanner you'll get full speed at 300 dpi even with all image
processing features enabled. http://p.sf.net/sfu/kodak-com
_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: logarithmic scale of colorbar with ticks and custom labels

Jae-Joon Lee
http://matplotlib.sourceforge.net/api/figure_api.html?highlight=colorbar#matplotlib.figure.Figure.colorbar

cbar = colorbar(ticks=lev, format = l_f)

-JJ


On Wed, May 6, 2009 at 3:28 PM, Sebastian Pająk <[hidden email]> wrote:

> Hello
>
> I have a contour plot with specified number of levels (isolines):
>
> lev = array([2,3,5,7,10,13,17,21,26,32,42,62,80,100,120,140,180])
>
> to have a log "z" axis I put:
>
> from matplotlib import colors
> contourf(x1, y1, z1, lev, norm=colors.LogNorm(lev[0],lev[len(lev)-1]))
>
> now, to get colorbar in log scale:
>
> from matplotlib.ticker import LogLocator, LogFormatter
> l_f = LogFormatter(10, labelOnlyBase=False)
> cbar = colorbar(format = l_f)
>
> But the colorbar doesn't have all tick's labels specified in "lev"
> variable. Ticks are placed correctly on the cbar, but only every
> second tick has a text label (yes 2, 5, 10 ... etc). What should I do
> to have ALL levels on colorbar labeled?
>
> ------------------------------------------------------------------------------
> The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your
> production scanning environment may not be a perfect world - but thanks to
> Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700
> Series Scanner you'll get full speed at 300 dpi even with all image
> processing features enabled. http://p.sf.net/sfu/kodak-com
> _______________________________________________
> Matplotlib-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>

------------------------------------------------------------------------------
The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your
production scanning environment may not be a perfect world - but thanks to
Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700
Series Scanner you'll get full speed at 300 dpi even with all image
processing features enabled. http://p.sf.net/sfu/kodak-com
_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: logarithmic scale of colorbar with ticks and custom labels

Sebastian Pająk
OK works. I didn't notice the ticks arg. Thanks again

Sebastian

2009/5/7 Jae-Joon Lee <[hidden email]>:

> http://matplotlib.sourceforge.net/api/figure_api.html?highlight=colorbar#matplotlib.figure.Figure.colorbar
>
> cbar = colorbar(ticks=lev, format = l_f)
>
> -JJ
>
>
> On Wed, May 6, 2009 at 3:28 PM, Sebastian Pająk <[hidden email]> wrote:
>> Hello
>>
>> I have a contour plot with specified number of levels (isolines):
>>
>> lev = array([2,3,5,7,10,13,17,21,26,32,42,62,80,100,120,140,180])
>>
>> to have a log "z" axis I put:
>>
>> from matplotlib import colors
>> contourf(x1, y1, z1, lev, norm=colors.LogNorm(lev[0],lev[len(lev)-1]))
>>
>> now, to get colorbar in log scale:
>>
>> from matplotlib.ticker import LogLocator, LogFormatter
>> l_f = LogFormatter(10, labelOnlyBase=False)
>> cbar = colorbar(format = l_f)
>>
>> But the colorbar doesn't have all tick's labels specified in "lev"
>> variable. Ticks are placed correctly on the cbar, but only every
>> second tick has a text label (yes 2, 5, 10 ... etc). What should I do
>> to have ALL levels on colorbar labeled?
>>
>> ------------------------------------------------------------------------------
>> The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your
>> production scanning environment may not be a perfect world - but thanks to
>> Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700
>> Series Scanner you'll get full speed at 300 dpi even with all image
>> processing features enabled. http://p.sf.net/sfu/kodak-com
>> _______________________________________________
>> Matplotlib-users mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>
>

------------------------------------------------------------------------------
The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your
production scanning environment may not be a perfect world - but thanks to
Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700
Series Scanner you'll get full speed at 300 dpi even with all image
processing features enabled. http://p.sf.net/sfu/kodak-com
_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Loading...