[Matplotlib-users] Assign labels to colorbar extensions (user or development issue)

2014-11-16 Thread j1
I am not sure if this is a user issue or a development issue.
Using version 1.4.2
My code allows the user to hone in on a specific contour range, by changing
the minimum and maximum of the contour and the number of levels.
I am using colorbar extend to prevent any white patches, as the data may
have values outside the contour range.

I want the extensions to have tick values but I can't seem to figure out,
how to do it?

This is my code

import numpy as np
import matplotlib.pyplot as plt
xi = np.array([0., 0.5, 1.0])#xi data
yi = np.array([0., 0.5, 1.0])#yi data
zi = np.array([[0., 1.0, 2.0],[0., 1.0, 2.0],[-0.1, 1.0, 2.0]])#zi data
n=5#number of levels of user specified range
umin=0.5#user defined minimum of contour
umax=1#user defined maximum of contout
u = np.linspace(umin, umax, n)#user specified contour levels
cbtics = np.hstack([zi.min(),u,zi.max()])#contour ticks including maximum
and minimum of zi
plt.contourf(xi, yi, zi, u, cmap=plt.cm.jet,extend='both')#plot contour
cbar=plt.colorbar(extendrect='True',extendfrac='auto',spacing='proportional')#plot
colorbar
print cbar.ax.get_ylim()#show y limits
print cbar.ax.get_yticks()#show yticks
plt.show()


Using the user entered values:
ylim are (-0.25, 1.25)
but the yticks are:
[ 0.   0.2  0.4  0.6  0.8  1. ] range from 0 to 1

I'm guessing that the difference between ylim (-0.25 to 1.25) and yticks (0
to 1) is that I am using extensions, so is there no way to update y ticks to
include the extensions so that I can  assign labels to the extensions?



--
View this message in context: 
http://matplotlib.1069221.n5.nabble.com/Assign-labels-to-colorbar-extensions-user-or-development-issue-tp44392.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

--
Comprehensive Server Monitoring with Site24x7.
Monitor 10 servers for $9/Month.
Get alerted through email, SMS, voice calls or mobile push notifications.
Take corrective actions from your mobile device.
http://pubads.g.doubleclick.net/gampad/clk?id=154624111iu=/4140/ostg.clktrk
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] [matplotlib-devel] Development issue: Assign labels to colorbar extensions

2014-11-16 Thread Eric Firing
On 2014/11/16, 10:21 AM, j1 wrote:
 I have posted this in the user sub forum as well because i'm not sure that it
 is a user issue or development issue.
 Information about my problem and my code are here

 http://matplotlib.1069221.n5.nabble.com/Assign-labels-to-colorbar-extensions-user-or-development-issue-td44392.html
 http://matplotlib.1069221.n5.nabble.com/Assign-labels-to-colorbar-extensions-user-or-development-issue-td44392.html

 Is it possible to assign tick labels/values to extensions?

You would have to do it manually; you can put marks and text anywhere 
you want in a matplotlib figure, but there is no mechanism for adding 
ticks to the extensions.  That's simply not what they are for.  They are 
intended only to indicate a single color to which values outside the 
vmin-to-vmax range of the norm are assigned.


 If so, how can I do it

It looks like you might be able to achieve what you want *without* using 
extensions, by using a custom colormap and/or norm.  You would extend 
the actual contour levels to include the full range you want ticked and 
labeled, but you would use the colormap and/or norm to ensure those 
beyond a given range are mapped to the appropriate end color(s).

Eric



--
Comprehensive Server Monitoring with Site24x7.
Monitor 10 servers for $9/Month.
Get alerted through email, SMS, voice calls or mobile push notifications.
Take corrective actions from your mobile device.
http://pubads.g.doubleclick.net/gampad/clk?id=154624111iu=/4140/ostg.clktrk
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users