|
From: Benjamin R. <ben...@ou...> - 2013-07-03 13:36:24
|
On Wed, Jul 3, 2013 at 3:13 AM, ChaoYue <cha...@gm...> wrote: > 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 > > Remember, there is a difference between a tick location, and a tick label. A colormap works from 0 to 1, so that is its data coordinates. We merely label the ticks with the appropriate values. Try cbar.ax.yaxis.get_ticklabels(). Cheers! Ben Root |