Spine.set_position unexpectedly clears axis

From: Andrew Straw [mailto:strawman@…36…]
Sent: Thursday, September 30, 2010 11:55

I'm setting up an axes in which I configure the axis objects with my desired tick locators and formatters and later configure the spines, setting their bounds, visibility, and positions. I was surprised that setting the spine position wiped my axis formatting by calling axis.cla(). Is it necessary that the spine must clear the registered axis when its position is changed? (The same clearing occurs in Spine.register_axis(), but in my case that occurs at axes creation and doesn't cause me any trouble.)

Hi Stan, IIRC, it has to do with forcing the axis elements to reconnect to the spine after it has a new transform. If you can think of a better way to do it, please give it a try. Simply deleting that call causes problems in some cases, such as in the demo multiple_yaxis_with_spines.py.

Thanks, Andrew. I tried using self.axis.reset_ticks() instead of self.axis.cla() in Spine.set_position(), and it was sufficient to give the correct results in multiple_yaxis_with_spines.py and spine_placement_demo.py. Going further, I made the same substitution in Spine.register_axis() and Spine.cla(), and the example plots still looked correct. (A patch is attached.) These latter substitutions seem okay internally, eliminating redundant executions of Axis.cla(): The only active calls to Spine.register_axis() are in Axes._init_axis() immediately following the instantiation of the axis objects, and the only call I found to Spine.cla() is in Axes.cla() right after self.xaxis.cla() and self.yaxis.cla() have occurred. Are these changes the way to go?

Along the way, I noticed that the polar and geographic axes in projections/polar.py and geo.py have commented-out calls to Spine.register_axis(), to avoid calling Axis.cla(). Does the patch help improve that situation?

spines.Spine.patch (824 Bytes)

···

On 09/29/2010 08:27 AM, Stan West wrote: