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: Gaël KANEKO <kanekogael@ho...>  20110214 10:23:50
Attachments:
Message as HTML

Hi, I have some problems to plot a 3d plot_surface (and contour plot) in log scale (y and z or x,y and z). There is nothink in the help sections of thus plot to plot them in log scale (neither in thus plot code commentary). I tried to find a solution by myself (many try as "log=True", "xscale='log'", "scale='log'", or "set_xscale('log')"...) but it doesn't work. I tried to use "LogFormatter" (ticker) but i failed (maybe I am doing something wrong (I am a newbe) but i tried many things). I try to found a solution on forums and this mailing list and what i found nearest of my problem is this topic: http://stackoverflow.com/questions/3909794/plottingmplot3daxes3dxyzsurfaceplotwithlogscale They said this problem had no solution. Is it true? have somebody solved this problem? An other solution is to plot log(Data) and change ticks with "set_ticks" (for exemple) but it seems to only work with 2D plot. I tried too :( To be unterstanding easier, this is an exemple of the code to plot in log scale: import matplotlib.pyplot as plt# (i am under '1.0.0') import numpy as np #Data x = np.logspace(0, 4, 10) y = np.logspace(0, 4, 10) Z = np.arange(100).reshape((10,10)) #Min and Max for x,y and Z minx=np.min(x) maxx=np.max(x) miny=np.min(y) maxy=np.max(y) minz=np.min(Z) maxz=np.max(Z) #figure fig = plt.figure() ax = fig.gca(projection='3d') ax.plot_surface(X, Y, Z, rstride=8, cstride=8, alpha=0.3) cset = ax.contour(X, Y, Z, zdir='z', offset=minz) cset = ax.contour(X, Y, Z, zdir='x', offset=minx) cset = ax.contour(X, Y, Z, zdir='y', offset=miny) ax.set_xlabel("X") ax.set_xlim3d(minx,maxx) ax.set_ylabel("Y") ax.set_ylim3d(miny,maxy) ax.set_zlabel("Z") ax.set_zlim3d(minz,maxz) fig.savefig("plot00.png") Has someone got a solution? Thanks! Regards, Gaël 
From: Benjamin Root <ben.root@ou...>  20110215 15:57:49
Attachments:
Message as HTML

2011/2/14 Gaël KANEKO <kanekogael@...> > Hi, > I have some problems to plot a 3d plot_surface (and contour plot) in log > scale (y and z or x,y and z). > There is nothink in the help sections of thus plot to plot them in log > scale (neither in thus plot code commentary). > I tried to find a solution by myself (many try as "log=True", > "xscale='log'", "scale='log'", or "set_xscale('log')"...) but it doesn't > work. > I tried to use "LogFormatter" (ticker) but i failed (maybe I am doing > something wrong (I am a newbe) but i tried many things). > I try to found a solution on forums and this mailing list and what i found > nearest of my problem is this topic: > > http://stackoverflow.com/questions/3909794/plottingmplot3daxes3dxyzsurfaceplotwithlogscale > They said this problem had no solution. Is it true? have somebody solved > this problem? > > An other solution is to plot log(Data) and change ticks with "set_ticks" > (for exemple) but it seems to only work with 2D plot. I tried too :( > > To be unterstanding easier, this is an exemple of the code to plot in log > scale: > import matplotlib.pyplot as plt# (i am under '1.0.0') > import numpy as np > > #Data > x = np.logspace(0, 4, 10) > y = np.logspace(0, 4, 10) > Z = np.arange(100).reshape((10,10)) > > #Min and Max for x,y and Z > minx=np.min(x) > maxx=np.max(x) > miny=np.min(y) > maxy=np.max(y) > minz=np.min(Z) > maxz=np.max(Z) > > #figure > fig = plt.figure() > ax = fig.gca(projection='3d') > > > ax.plot_surface(X, Y, Z, rstride=8, cstride=8, alpha=0.3) > cset = ax.contour(X, Y, Z, zdir='z', offset=minz) > cset = ax.contour(X, Y, Z, zdir='x', offset=minx) > cset = ax.contour(X, Y, Z, zdir='y', offset=miny) > > ax.set_xlabel("X") > ax.set_xlim3d(minx,maxx) > ax.set_ylabel("Y") > ax.set_ylim3d(miny,maxy) > ax.set_zlabel("Z") > ax.set_zlim3d(minz,maxz) > fig.savefig("plot00.png") > > > > Has someone got a solution? > Thanks! > Regards, > Gaël > > I can confirm (with a modified version of your script) that mplot3d does not properly handle nonlinear scaling. While it is possible to set the axis scale through a command like: ax.w_xaxis.set_scale('log') but the placement of the tickers are wrong and it fails because mplot3d does some weird stuff with the ticker formatter rather than just letting the formatter do its job. I will look into this further to see if I can fix this. Ben Root 
Sign up for the SourceForge newsletter:
No, thanks