Screenshot instructions:
Windows
Mac
Red Hat Linux
Ubuntu
Click URL instructions:
Rightclick on ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)
From: Trevor Irons <trevorirons@gm...>  20091208 16:12:09
Attachments:
Message as HTML

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: raise MaskError, 'Cannot convert masked element to a Python int.' numpy.ma.core.MaskError: Cannot convert masked element to a Python int. 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. 
From: Reinier Heeres <reinier@he...>  20091213 23:23:07

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@...> 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: > raise MaskError, 'Cannot convert masked element to a Python int.' > numpy.ma.core.MaskError: Cannot convert masked element to a Python int. > > 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 
From: Trevor Irons <trevorirons@gm...>  20091214 15:35:15
Attachments:
Message as HTML

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@...> > 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@...> > 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: > > raise MaskError, 'Cannot convert masked element to a Python int.' > > numpy.ma.core.MaskError: Cannot convert masked element to a Python int. > > > > 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 > 
Sign up for the SourceForge newsletter:
No, thanks