Thanks Ben. I tried but still confused.

In [8]: fig,ax = plt.subplots()

In [9]: ax.plot(range(100))
Out[9]: [<matplotlib.lines.Line2D at 0x4cadb50>]

In [10]: ax.get_xticks()
Out[10]: array([   0.,   20.,   40.,   60.,   80.,  100.])

In [11]: ax.get_yticks()
Out[11]: array([   0.,   20.,   40.,   60.,   80.,  100.])

In [12]: draw()

In [13]: cs = ax.imshow(np.arange(100).reshape(10,10))

In [14]: draw()

In [15]: cbar = plt.colorbar(cs,ticks=np.arange(0,100,10))

In [16]: cbar.ax.get_yticks()
Out[16]:
array([ 0.        ,  0.1010101 ,  0.2020202 ,  0.3030303 ,  0.4040404 ,
        0.50505051,  0.60606061,  0.70707071,  0.80808081,  0.90909091])

there are many methods avaialbe for cbar.ax.yaxis object:
In [19]: cbar.ax.yaxis.get*tick*?
cbar.ax.yaxis.get_major_ticks
cbar.ax.yaxis.get_majorticklabels
cbar.ax.yaxis.get_majorticklines
cbar.ax.yaxis.get_majorticklocs
cbar.ax.yaxis.get_minor_ticks
cbar.ax.yaxis.get_minorticklabels
cbar.ax.yaxis.get_minorticklines
cbar.ax.yaxis.get_minorticklocs
cbar.ax.yaxis.get_ticklabel_extents
cbar.ax.yaxis.get_ticklabels
cbar.ax.yaxis.get_ticklines
cbar.ax.yaxis.get_ticklocs
cbar.ax.yaxis.get_ticks_position

I tried
In [20]: cbar.ax.yaxis.get_majorticklocs()
Out[20]:
array([ 0.        ,  0.1010101 ,  0.2020202 ,  0.3030303 ,  0.4040404 ,
        0.50505051,  0.60606061,  0.70707071,  0.80808081,  0.90909091])

But it doesn't give the tick locs as the normal axes?

could you explain a bit further?

thanks et cheers,

Chao



On Tue, Jul 2, 2013 at 4:17 PM, Benjamin Root-2 [via matplotlib] <
ml-node+s1069221n41365...@n5.nabble.com> wrote:

> This is a constant source of confusion.  The colorbar object should be
> thought of as just another subaxes.  To get the ticks, you want the ticks
> from the colorbar's yaxis or xaxis object accordingly.  Of course, I could
> have sworn we added a helper function for this at some point, but I could
> be wrong.
>
> I hope that helps!
> Ben Root
>
>
> On Tue, Jul 2, 2013 at 5:43 AM, Chao YUE <[hidden 
> email]<http://user/SendEmail.jtp?type=node&node=41365&i=0>
> > wrote:
>
>> Dear all matplotlib users,
>>
>> I found there is not a get_ticks method available for colorbar instance,
>> how could I quick get the ticks of a colorbar?
>>
>> thanks,
>>
>> Chao
>> --
>>
>> ***********************************************************************************
>> Chao YUE
>> Laboratoire des Sciences du Climat et de l'Environnement (LSCE-IPSL)
>> UMR 1572 CEA-CNRS-UVSQ
>> Batiment 712 - Pe 119
>> 91191 GIF Sur YVETTE Cedex
>> Tel: (33) 01 69 08 29 02; Fax:01.69.08.77.16
>>
>> ************************************************************************************
>>
>>
>> ------------------------------------------------------------------------------
>> This SF.net email is sponsored by Windows:
>>
>> Build for Windows Store.
>>
>> http://p.sf.net/sfu/windows-dev2dev
>> _______________________________________________
>> Matplotlib-users mailing list
>> [hidden email] <http://user/SendEmail.jtp?type=node&node=41365&i=1>
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>
>>
>
> ------------------------------------------------------------------------------
>
> This SF.net email is sponsored by Windows:
>
> Build for Windows Store.
>
> http://p.sf.net/sfu/windows-dev2dev
> _______________________________________________
> Matplotlib-users mailing list
> [hidden email] <http://user/SendEmail.jtp?type=node&node=41365&i=2>
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
> ------------------------------
>  If you reply to this email, your message will be added to the discussion
> below:
>
> http://matplotlib.1069221.n5.nabble.com/quickly-return-colorbar-ticks-tp41361p41365.html
>  To start a new topic under matplotlib - users, email
> ml-node+s1069221n...@n5.nabble.com
> To unsubscribe from matplotlib, click 
> here<http://matplotlib.1069221.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=2&code=Y2hhb3l1ZWpveUBnbWFpbC5jb218MnwxMzg1NzAzMzQx>
> .
> NAML<http://matplotlib.1069221.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>



-- 
***********************************************************************************
Chao YUE
Laboratoire des Sciences du Climat et de l'Environnement (LSCE-IPSL)
UMR 1572 CEA-CNRS-UVSQ
Batiment 712 - Pe 119
91191 GIF Sur YVETTE Cedex
Tel: (33) 01 69 08 29 02; Fax:01.69.08.77.16
************************************************************************************




--
View this message in context: 
http://matplotlib.1069221.n5.nabble.com/quickly-return-colorbar-ticks-tp41361p41384.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:

Build for Windows Store.

http://p.sf.net/sfu/windows-dev2dev
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to