From: John H. <jd...@gm...> - 2007-09-28 12:41:43
|
On 9/27/07, Charles Seaton <cs...@st...> wrote: > I am having the same problem as Eugen, and the suggested solution of using > a.xaxis.get_major_locator().refresh() > to force the creation of the full set of ticklabels doesn't seem to work for > me. matplotlib creates a prototypical tick (the prototick) and then creates new ones on as as needed basis, copying properties from the prototick. Of course, position is one of the properties that cannot be copied, which is why you are having trouble in your example. Fortunately, there is an easy solution. Call ax.xaxis.get_major_ticks() and access the label attribute: for tick in ax.xaxis.get_major_ticks(): label = tick.label1 Axis.get_major_ticks will force a call to the locator and update the tick list. The Axes methods like get_xticklabels are just working on the existing tick list rather than calling the get_major_ticks method which is why you are not getting the full list. This is a bug. I just made changes in svn so that all the accessor methods (ax.get_xticklines, ax.get_yticklabels, and friends) all trigger a call to axis.get_major_ticks rather so they should give the same results going forward. JDH FYI, the Tick attributes are: tick1line : a Line2D instance tick2line : a Line2D instance gridline : a Line2D instance label1 : a Text instance label2 : a Text instance gridOn : a boolean which determines whether to draw the tickline tick1On : a boolean which determines whether to draw the 1st tickline tick2On : a boolean which determines whether to draw the 2nd tickline label1On : a boolean which determines whether to draw tick label label2On : a boolean which determines whether to draw tick label |