 # 3D semilog plot

Hi:

I’m trying to get a semilog 3D plot. I want to plot several 2D time series lines, with the third axis being on a log scale. I am trying to set an axis to log using ax.set_yscale(‘log’), but am getting errors. Is this possible?

I keep getting numpy errors when I try:

My attempt:

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

fig = plt.figure()
#ax = fig.gca()
ax = Axes3D(fig)

colors = (‘r’, ‘g’, ‘b’, ‘k’)
zd = (0., 1., 2., 3.)
T2 = (0.9, .8, .7, .6)
ic = 1

for ic in xrange(len(colors)):
x = np.arange(0.05,1,.005)
z = np.exp(-x/T2[ic]) + np.random.normal(0, .05, len(x))
y = np.exp(zd[ic])*np.ones(len(x))
ax.plot(x,y,z)

# Error if uncommented

#ax.set_yscale(‘log’)
plt.show()

Thanks for any insight.

Hi,

You'll have to use ax.w_yaxis.set_yscale('log'), which should work fine.

Hope this helps,
Reinier

···

On Tue, Dec 8, 2009 at 5:11 PM, Trevor Irons <trevorirons@...287...> wrote:

Hi:

I'm trying to get a semilog 3D plot. I want to plot several 2D time series
lines, with the third axis being on a log scale. I am trying to set an axis
to log using ax.set_yscale('log'), but am getting errors. Is this possible?

I keep getting numpy errors when I try:

My attempt:

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

fig = plt.figure()
#ax = fig.gca()
ax = Axes3D(fig)

colors = ('r', 'g', 'b', 'k')
zd = (0., 1., 2., 3.)
T2 = (0.9, .8, .7, .6)
ic = 1

for ic in xrange(len(colors)):
x = np.arange(0.05,1,.005)
z = np.exp(-x/T2[ic]) + np.random.normal(0, .05, len(x))
y = np.exp(zd[ic])*np.ones(len(x))
ax.plot(x,y,z)

# Error if uncommented
#ax.set_yscale('log')
plt.show()

Thanks for any insight.

--
Reinier Heeres
Tel: +31 6 10852639

Thanks,

This almost does what I want. The labels are now changed to log notation, but the tick locations have remained the same. I want the spacing between each logarithmic decade to be equal. I just did an svn up and rebuild so I am working with bleeding edge matplotlib. Do I need to manually set the locations of the ticks? I’ll play around a bit more with w_yaxis, I wasn’t aware of this.

Danke vel,

Trevor

2009/12/13 Reinier Heeres <reinier@…2663…>

···

Hi,

You’ll have to use ax.w_yaxis.set_yscale(‘log’), which should work fine.

Hope this helps,

Reinier

On Tue, Dec 8, 2009 at 5:11 PM, Trevor Irons <trevorirons@…287…> wrote:

Hi:

I’m trying to get a semilog 3D plot. I want to plot several 2D time series

lines, with the third axis being on a log scale. I am trying to set an axis

to log using ax.set_yscale(‘log’), but am getting errors. Is this possible?

I keep getting numpy errors when I try:

My attempt:

from mpl_toolkits.mplot3d import Axes3D

import matplotlib.pyplot as plt

import numpy as np

fig = plt.figure()

#ax = fig.gca()

ax = Axes3D(fig)

colors = (‘r’, ‘g’, ‘b’, ‘k’)

zd = (0., 1., 2., 3.)

T2 = (0.9, .8, .7, .6)

ic = 1

for ic in xrange(len(colors)):

``````x = np.arange(0.05,1,.005)
``````
``````z = np.exp(-x/T2[ic]) + np.random.normal(0, .05, len(x))
``````
``````y = np.exp(zd[ic])*np.ones(len(x))
``````
``````ax.plot(x,y,z)
``````

# Error if uncommented

#ax.set_yscale(‘log’)

plt.show()

Thanks for any insight.

Reinier Heeres

Tel: +31 6 10852639