Axes labels crooked using mplot3d in WX

I'm trying to use mplot3d in a Wx based application, and most things seem to
be working fine. The one issue that keeps tripping me up is that the axes
labels are drawn at a weird angle. If I do the same type of plot without
using wx, then this problem goes away. I am completely stumped as to where
to even begin looking to fix this problem, so I would appreciate any
pointers you can give me.

I've attached a screenshot showing what I am talking about - a simple plot
where the axes labels look strange.

http://old.nabble.com/file/p30184616/mplot3d.jpg

···

--
View this message in context: http://old.nabble.com/Axes-labels-crooked-using-mplot3d-in-WX-tp30184616p30184616.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

I can reproduce the weird angle issue, but I can’t seem to find a backend where it doesn’t occur. Could you run “import matplotlib; print matplotlib.get_backend()” to determine which backend you are using when everything looks ok? Also, could you report the output of “matplotlib.version”?

If it happens for all backends then the problem is in mplot3d/axis3d.py. Unfortunately, the code there is a little light on commenting, but i don’t notice any glaring mathematical error off the bat.

Ben Root

···

On Wed, Nov 10, 2010 at 3:12 PM, unij <jdavidheiser@…3347…6…> wrote:

I’m trying to use mplot3d in a Wx based application, and most things seem to

be working fine. The one issue that keeps tripping me up is that the axes

labels are drawn at a weird angle. If I do the same type of plot without

using wx, then this problem goes away. I am completely stumped as to where

to even begin looking to fix this problem, so I would appreciate any

pointers you can give me.

I’ve attached a screenshot showing what I am talking about - a simple plot

where the axes labels look strange.

http://old.nabble.com/file/p30184616/mplot3d.jpg

I’m trying to use mplot3d in a Wx based application, and most things seem to
be working fine. The one issue that keeps tripping me up is that the axes
labels are drawn at a weird angle. If I do the same type of plot without
using wx, then this problem goes away. I am completely stumped as to where
to even begin looking to fix this problem, so I would appreciate any
pointers you can give me.

I’ve attached a screenshot showing what I am talking about - a simple plot
where the axes labels look strange.

http://old.nabble.com/file/p30184616/mplot3d.jpg

I can reproduce the weird angle issue, but I can’t seem to find a backend where it doesn’t occur. Could you run “import matplotlib; print matplotlib.get_backend()” to determine which backend you are using when everything looks ok? Also, could you report the output of “matplotlib.version”?

If it happens for all backends then the problem is in mplot3d/axis3d.py. Unfortunately, the code there is a little light on commenting, but i don’t notice any glaring mathematical error off the bat.

Ben Root

That’s actually a really good point and something I didn’t explain well – I didn’t go out of my way to test with other backends, but rather I tried it by recreating the plot independently of my GUI, creating the same plot using pyplot, following the example in scatter3d_demo.py from the sourceforge demos page. If I then import matplotlib and check the backend, I get that it’s TkAgg, but I’m not sure whether that backend is actually being used – is it?

I did just try changing between Wx and WxAgg for the backends, and the positions of the labels definitely move around in weird ways between the two, so I think I’m now even more confused than I was before.

James

···

From: ben.v.root@…287… [mailto:ben.v.root@…287…] On Behalf Of Benjamin Root
On Wed, Nov 10, 2010 at 3:12 PM, unij <jdavidheiser@…3346…> wrote:

The difference between a gui kit like Wx and its Agg equivalent is probably expected. Agg renderers bring additional capabilities and functionality with respect to rendering special vector-based graphics such as fonts. For example, while examining this bug, I noticed that the GTK backend can only represent fonts with either a 0 degree rotation, or 90 degree rotation, while the GTKAgg doesn’t have that limitation.

I have tested Wx, WxAgg, GTK, GTKAgg, QTAgg, QT4Agg, and TkAgg and have found them all to be rotating the text incorrectly. GTK doesn’t rotate at all, and emits an error (I wonder if we can catch this and perform an appropriate failback?). Wx does not appear to be performing the translation step properly, causing the label to appear on top of the tick labels. The other backends all seem to have similar results.

I wonder if the calculation for the text angle is off because maybe it is not using all 3 dimensions? In other words, the text appear to fail to take into account depth perception. I will take another peek at the code and see what I can figure out.

Ben Root

···

On Thu, Nov 11, 2010 at 8:49 AM, James Davidheiser <jdavidheiser@…3346…> wrote:

From: ben.v.root@…287… [mailto:ben.v.root@…287…] On Behalf Of Benjamin Root

On Wed, Nov 10, 2010 at 3:12 PM, unij <jdavidheiser@…3346…> wrote:

I’m trying to use mplot3d in a Wx based application, and most things seem to
be working fine. The one issue that keeps tripping me up is that the axes
labels are drawn at a weird angle. If I do the same type of plot without

using wx, then this problem goes away. I am completely stumped as to where
to even begin looking to fix this problem, so I would appreciate any
pointers you can give me.

I’ve attached a screenshot showing what I am talking about - a simple plot

where the axes labels look strange.

http://old.nabble.com/file/p30184616/mplot3d.jpg

I can reproduce the weird angle issue, but I can’t seem to find a backend where it doesn’t occur. Could you run “import matplotlib; print matplotlib.get_backend()” to determine which backend you are using when everything looks ok? Also, could you report the output of “matplotlib.version”?

If it happens for all backends then the problem is in mplot3d/axis3d.py. Unfortunately, the code there is a little light on commenting, but i don’t notice any glaring mathematical error off the bat.

Ben Root

That’s actually a really good point and something I didn’t explain well – I didn’t go out of my way to test with other backends, but rather I tried it by recreating the plot independently of my GUI, creating the same plot using pyplot, following the example in scatter3d_demo.py from the sourceforge demos page. If I then import matplotlib and check the backend, I get that it’s TkAgg, but I’m not sure whether that backend is actually being used – is it?

I did just try changing between Wx and WxAgg for the backends, and the positions of the labels definitely move around in weird ways between the two, so I think I’m now even more confused than I was before.

James