From: John H. <jdh...@ac...> - 2006-08-29 04:13:33
|
>>>>> "Jouni" =3D=3D Jouni K Sepp=E4nen <jk...@ik...> writes: Jouni> How I came up with this: I knew that I wanted to make some Jouni> of the xticklines invisible, so I looked at the list of Jouni> line objects for clues as to what differs between Jouni> them. They seem to have xdata and ydata properties, and Jouni> ydata is (0,) for half of the lines and (1,) for the other Jouni> half, so it looks like it is the vertical position in axis Jouni> coordinates. (xdata seems to be in data coordinates.) Off the top of my head, I didn't remember the answer either. Here's how I answered it: I opened up lib/matplotlib/axis.py in my local copy of the mpl src distro and searched for Tick (you could have done the same by pointing your browser to http://matplotlib.sourceforge.net/matplotlib.axis.html#Tick) and saw the following attributes in the docstring Publicly accessible attributes 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 ticklin= e tick1On : a boolean which determines whether to draw the 1st tic= kline tick2On : a boolean which determines whether to draw the 2nd tic= kline label1On : a boolean which determines whether to draw tick label label2On : a boolean which determines whether to draw tick label I know, and it should be better documented, that for the x-axis, the tick1 and label1 designations are for the lower axis, and the tick2 and label2 are for the upper (ditto for left/right for the y-axis). So tick.tick1line controls the properties for the lower tick, etc. Thus one can do for tick in ax.xaxis.get_major_ticks(): tick.tick1line.set_visible(False) tick.label2.set_color('darkslategray') As Jouni notes, the documentation could and should be better, but the underlying concepts are pretty simple. A Figure contains multiple Axes, each of which contains an XAxis and YAxis. The XAxis and Yaxis contains XTicks and YTicks, and these contains tick lines (Line2D instances) and tick labels (Text instances). Each of these upper-case thingies is a well-documented matplotlib class (this class containment hierarchy is also documented in the user's guide). For future reference, the links to the class documentation for each of these is Figure : http://matplotlib.sourceforge.net/matplotlib.figure.html Axes/Subplot : http://matplotlib.sourceforge.net/matplotlib.axes.html XAxis/YAxis : http://matplotlib.sourceforge.net/matplotlib.axis.html XTick/YTick : http://matplotlib.sourceforge.net/matplotlib.axis.html Line2D : http://matplotlib.sourceforge.net/matplotlib.lines.html Text : http://matplotlib.sourceforge.net/matplotlib.text.html As Jouni notes, setp and getp are a nice way to get quick interactive access to the configurable properties, but they are also documented in the class documentation in the links above. JDH |