Ticks and Axes for 3d plotting

Hi,

Two related questions. Consider this plot

···

-----

import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D

fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
ax.plot([1,0,0,1],[0,1,0,0],[0,0,1,0])

ax.set_xlim3d(0,1)
ax.set_ylim3d(0,1)
#ax.set_ylim3d(1,0)
ax.set_zlim3d(0,1)

plt.show()

-----

I want to uncomment the line above to reverse the y axis, but as soon
as I do, the tick labels disappear on the y axis and the z axis tick
label padding changing. Is there another way to reverse the y axis, or
should I fix thing after the fact. If so, how can I do this? I don't
see a zaxis in rcParams.

Thanks,

Skipper

The first would be a bug (could you please file one?). The second should probably be a feature request, but I wouldn’t expect anything for that right away.

Ben Root

···

On Tue, Nov 8, 2011 at 4:55 PM, Skipper Seabold <jsseabold@…287…> wrote:

Hi,

Two related questions. Consider this plot


import matplotlib.pyplot as plt

from mpl_toolkits.mplot3d import Axes3D

fig = plt.figure()

ax = fig.add_subplot(111, projection=‘3d’)

ax.plot([1,0,0,1],[0,1,0,0],[0,0,1,0])

ax.set_xlim3d(0,1)

ax.set_ylim3d(0,1)

#ax.set_ylim3d(1,0)

ax.set_zlim3d(0,1)

plt.show()


I want to uncomment the line above to reverse the y axis, but as soon

as I do, the tick labels disappear on the y axis and the z axis tick

label padding changing. Is there another way to reverse the y axis, or

should I fix thing after the fact. If so, how can I do this? I don’t

see a zaxis in rcParams.

1. mplot3d reverse axis behavior · Issue #570 · matplotlib/matplotlib · GitHub
2. Surely there's another workaround in the meantime? I've never
worked much with rcParams, going the long way instead, but now that
I've discovered it, it's my preferred way of doing things. Anyone have
any ideas?

Skipper

···

On Tue, Nov 8, 2011 at 6:13 PM, Benjamin Root <ben.root@...1304...> wrote:

On Tue, Nov 8, 2011 at 4:55 PM, Skipper Seabold <jsseabold@...287...> wrote:

Hi,

Two related questions. Consider this plot

-----

import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D

fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
ax.plot([1,0,0,1],[0,1,0,0],[0,0,1,0])

ax.set_xlim3d(0,1)
ax.set_ylim3d(0,1)
#ax.set_ylim3d(1,0)
ax.set_zlim3d(0,1)

plt.show()

-----

I want to uncomment the line above to reverse the y axis, but as soon
as I do, the tick labels disappear on the y axis and the z axis tick
label padding changing. Is there another way to reverse the y axis, or
should I fix thing after the fact. If so, how can I do this? I don't
see a zaxis in rcParams.

The first would be a bug (could you please file one?). The second should
probably be a feature request, but I wouldn't expect anything for that right
away.

Hi,

Two related questions. Consider this plot


import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D

fig = plt.figure()
ax = fig.add_subplot(111, projection=‘3d’)

ax.plot([1,0,0,1],[0,1,0,0],[0,0,1,0])

ax.set_xlim3d(0,1)
ax.set_ylim3d(0,1)
#ax.set_ylim3d(1,0)
ax.set_zlim3d(0,1)

plt.show()


I want to uncomment the line above to reverse the y axis, but as soon
as I do, the tick labels disappear on the y axis and the z axis tick

label padding changing. Is there another way to reverse the y axis, or
should I fix thing after the fact. If so, how can I do this? I don’t
see a zaxis in rcParams.

The first would be a bug (could you please file one?). The second should
probably be a feature request, but I wouldn’t expect anything for that right
away.

  1. https://github.com/matplotlib/matplotlib/issues/570

Thanks.

  1. Surely there’s another workaround in the meantime? I’ve never

worked much with rcParams, going the long way instead, but now that
I’ve discovered it, it’s my preferred way of doing things. Anyone have
any ideas?

The problem is that mplot3d doesn’t query for any params yet. A lot of defaults are hard-coded. I would like to start adding defaults, but we will need to figure out a consistent naming scheme.

Ben Root

···

On Tuesday, November 8, 2011, Skipper Seabold <jsseabold@…287…> wrote:

On Tue, Nov 8, 2011 at 6:13 PM, Benjamin Root <ben.root@…1304…> wrote:

On Tue, Nov 8, 2011 at 4:55 PM, Skipper Seabold <jsseabold@…287…> wrote:

File under duh. The answer is just to adjust my plot coordinates
accordingly and fix the label. For example,

import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D

alpha = [4,4,2]
nobs = 2000

# draw the r.v.s
p1,p2,p3 = np.random.dirichlet(alpha, size=nobs).T

fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
#NOTE: 1 - p2 to reverse the y-axis
ax.scatter(p1, 1-p2, p3, zdir='z',s=2)

# plot the simplex with adjusted y coordinates
ax.plot([1,0,0,1],[1,0,1,1],[0,0,1,0])

ax.set_xlim3d(0,1)
ax.set_ylim3d(0,1)
# reverse the tick labels
ax.set_yticklabels([1.0, .8, .6, .4, .2, 0.0])
ax.set_zlim3d(0,1)
ax.set_title("Dirichlet(4,4,2) on the 2-simplex")

plt.show()

Skipper

···

On Tue, Nov 8, 2011 at 8:53 PM, Benjamin Root <ben.root@...1304...> wrote:

On Tuesday, November 8, 2011, Skipper Seabold <jsseabold@...287...> wrote:

On Tue, Nov 8, 2011 at 6:13 PM, Benjamin Root <ben.root@...1304...> wrote:

On Tue, Nov 8, 2011 at 4:55 PM, Skipper Seabold <jsseabold@...287...> >>> wrote:

Hi,

Two related questions. Consider this plot

-----

import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D

fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
ax.plot([1,0,0,1],[0,1,0,0],[0,0,1,0])

ax.set_xlim3d(0,1)
ax.set_ylim3d(0,1)
#ax.set_ylim3d(1,0)
ax.set_zlim3d(0,1)

plt.show()

-----

I want to uncomment the line above to reverse the y axis, but as soon
as I do, the tick labels disappear on the y axis and the z axis tick
label padding changing. Is there another way to reverse the y axis, or
should I fix thing after the fact. If so, how can I do this? I don't
see a zaxis in rcParams.

The first would be a bug (could you please file one?). The second should
probably be a feature request, but I wouldn't expect anything for that
right
away.

1. mplot3d reverse axis behavior · Issue #570 · matplotlib/matplotlib · GitHub

Thanks.

2. Surely there's another workaround in the meantime? I've never
worked much with rcParams, going the long way instead, but now that
I've discovered it, it's my preferred way of doing things. Anyone have
any ideas?

The problem is that mplot3d doesn't query for any params yet. A lot of
defaults are hard-coded. I would like to start adding defaults, but we will
need to figure out a consistent naming scheme.