>>>>> "Michael" == Michael Fitzgerald <[EMAIL PROTECTED]> writes:
Michael> Hi all, Michael> I'm still having trouble figuring out what's going on Michael> with tick labels. I can't figure out why Michael> Axes.get_{x,y}ticklabels() is returning a list of length Michael> unity when I expect to have the list of all labels. Michael> If I run the code below (test.py), I expect a list of 9 x Michael> tick labels. If I run the code once ('run test' in Michael> ipython), then it gives me a list of 1 tick label. If I Michael> close the interactive window it generates and run it Michael> again, it again returns 1 tick label. However, if I Michael> leave the window open and re-run the test, it gives the Michael> right answer. Michael> Can anyone else reproduce this? Is there something I'm Michael> missing? I'm using svn rev 2730 of matplotlib, and I Michael> think this is new behavior in the last couple months. It's a feature, not a bug :-) Here is what is happening. matplotlib allocates a different number of ticks depending on the zoom level, and the axis seeds itself with a single tick called the "protoTick". If you zoom to the right and new ticks need to be created, the properties from the protoTick are copied to the newly created ticks. 99% of the time, this is what you want. If you have large bold tick labels, and zoom to the right, you want the new ticks that appear to be large and bold. So this explains why you see a single tick before the window is drawn (the protoTick), a list of ticks after the window is drawn, and why the properties of the first tick (the "visible" property in this case) are transferred to the other ticks. So: how do you solve your problem, of making the first tick invisible? What I do when I need to solve this problem, which comes up a lot with multiple axes where ticks can overlap, is the following from matplotlib.ticker import ScalarFormatter class MyFormatter(ScalarFormatter): def __call__(self, x, pos=None): if pos==0: return '' else: return ScalarFormatter(self, x, pos) ax.xaxis.set_major_formatter(MyFormatter()) I often want to do this for the last tick as well, but there is currently no convenient way to do this, as the tick locator produces the tick location list and the tick formatter doesn't know how many of them there are. I've been considering modifying the tick locator code to pass -1 for the pos for the last tick to solve just this use case. If others need this or think it desirable, just give me a nudge and I'll do it. Details about the tick locators and formatter can be found at http://matplotlib.sourceforge.net/matplotlib.ticker.html and there are a number of examples ~/mpl/examples> grep -l Formatter *.py custom_ticker1.py dashtick.py date_demo1.py date_demo2.py date_demo_rrule.py finance_demo.py major_minor_demo1.py major_minor_demo2.py newscalarformatter_demo.py shared_axis_demo.py Hope this helps, JDH ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users