From: Christian D. O. <chr...@gm...> - 2005-11-19 00:34:56
|
Hi, using the PS Backend and matplotlib 0.82 with python 2.3.5 I have the problem that my graphs typically show up on top of the axes lines (the figure frame) and tick marks. However, for a journal quality figure, I need the axes and the tick marks to be on top of the graph(s). I looked through the archives and found below e-mail. Has there been any progress in fixing this? Has Michael Brady submitted a patch? Thanks. - Christian ***************************************************************** >>>>> "Michael" =3D=3D Michael Brady <mbrady@jp...> writes: Michael> I tried setting the z-order of the tick objects, but it Michael> looks to me like the ticks are hard-coded to always draw Michael> before (underneath) any lines or patches. That"s right, they are. This is a bug and not a feature :-( The ticks are drawn as part of the Axis. See matplotlib.axes.Axes.draw, eg if self.axison: self.xaxis.draw(renderer) self.yaxis.draw(renderer) The Axis instances (XAxis and YAxis) are comprised of Line2D (the ticks) and Text (the labels) instances. Michael> Is there a way to tell the Axes to draw the ticks on top Michael> of any Polygons instead of underneath? As noted above, before any of the zorder sorting is done, the xaxis and yaxis are drawn. One possible solution is to move the axis drawing commands to the end of the Axes.draw function. Off the top of my head, I don"t see any problem with this approach. Typically, you want the ticks visible. We"ve talked in the past on the dev list about the desirability in supporting ticking inside, center or outside the axes box, but it hasn"t been implemented yet. Vis-a-vis zorder sorting, a more general solution would be to have a method which extracts the Artist primitives (Line2D and Text) from the XAxis and YAxis and adds them to the sort, but I"m not sure if this is actually better. In real life, I think you always want them on top. Right? Michael> If not, it doesn"t look like it would be too hard to Michael> modify Axes.draw() to respect the z-order of ticks. I"m Michael> happy to do this, although I"m nervous that it might Michael> break stuff that assumes that ticks are always drawn Michael> before everything else. John, do you recommend that I Michael> create such a mod? Yes, if you can find something that works, and behaves sanely over the poorman"s unit tests in examples/backend_driver.py. JDH |
From: Christian D. O. <chr...@gm...> - 2005-11-19 12:45:11
|
Hi, sorry about my previous e-mail. I have now tried the same with 0.85. The tick marks are now by default on top of the data graphs while the axes lines (please correct my vocabulary usage here, axes lines =3D figure frame?) are still below. To get the figure frame drawn on top of everything, one has to modify axes.draw. Namely, one adds to if not self._axisbelow: if self.axison and not inframe: self.xaxis.draw(renderer) self.yaxis.draw(renderer) these 4 lines: if self.axison: if self._frameon: self.axesPatch.set_fill(False) self.axesPatch.draw(renderer) . Also, one has to set gca.set_axisbelow(False) for the if block to be executed. The additional code draws another figure frame, this time without filling, on top of the previous one and the data graphs. - Christian On 11/19/05, Christian David Ott wrote: > Hi, > > using the PS Backend and matplotlib 0.82 with python 2.3.5 I have the > problem that my graphs typically show up on top of the axes lines (the > figure frame) and tick marks. However, for a journal quality figure, I > need the axes and the tick marks to be on top of the graph(s). > > I looked through the archives and found below e-mail. Has there been > any progress in fixing this? Has Michael Brady submitted a patch? > > Thanks. > > - Christian > > |
From: John H. <jdh...@ac...> - 2005-11-19 13:40:35
|
>>>>> "Christian" == Christian David Ott <chr...@gm...> writes: Christian> Hi, sorry about my previous e-mail. I have now tried Christian> the same with 0.85. The tick marks are now by default Yep, the axisbelow property was just added in 0.85 and this controls whether the ticks and grid lines are drawn above or below your data lines. Christian> on top of the data graphs while the axes lines (please Christian> correct my vocabulary usage here, axes lines = figure Christian> frame?) are still below. I see the source of our previous confusion -- matplotlib has a figure patch and an axes patch. The figure patch controls the backgroud of the entire figure canvas and the frame of this borders your window or paper. The axes patch is the thing surrounding the subplot/axes (eg the white area where your data are). I think in your previous emails when you referred to the "figure frame" you meant the axes frame. In which case you would use subplot(111, frameon=False) Christian> To get the figure frame drawn on top of everything, one Christian> has to modify axes.draw. Namely, one adds to Christian> these 4 lines: Christian> if self.axison: if self._frameon: Christian> self.axesPatch.set_fill(False) Christian> self.axesPatch.draw(renderer) So basically, you want a second draw of the axespatch edge over the ticks. Could you post a script w/o these changes that shows the undesirable effect, so I can see better what the problem is. I worry that doing two draws of the axes patch, one w/ the fill first and one w/o the fill later will screw up the alpha channel of the edgecolor of the axes patch. Albeit a corner case. JDH |