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: Richard Hofmeister <richard.hofmeister@io...>  20110609 11:26:01
Attachments:
Message as HTML

Hello mplot3d specialists, I would like to change the aspect ratio of the 3d axes similar to matlab's functionality with daspect() or the 'dataaspectratio' property of 3daxes. In the end, the xyplane should be nonsquare due to different lengths (not range) of the x and y axis (i know that i can use the aspect property of the axes to set the xz/yz aspect ratio). There is also the package "scitools", which provides all the matlab3d functions including daspect via a VTKbackend; that would be my next try. For the simple 3dplotting without fancy shading, i would like to stick to mplot3d: Is it possible to change the axis lengths/aspect ratios independently? Richard 
From: Benjamin Root <ben.root@ou...>  20110609 15:13:45
Attachments:
Message as HTML

On Thu, Jun 9, 2011 at 6:25 AM, Richard Hofmeister < richard.hofmeister@...> wrote: > Hello mplot3d specialists, > > I would like to change the aspect ratio of the 3d axes similar to matlab's > functionality with daspect() or the 'dataaspectratio' property of 3daxes. > In the end, the xyplane should be nonsquare due to different lengths > (not range) of the x and y axis (i know that i can use the aspect property > of the axes to set the xz/yz aspect ratio). > > There is also the package "scitools", which provides all the matlab3d > functions including daspect via a VTKbackend; that would be my next try. > > For the simple 3dplotting without fancy shading, i would like to stick to > mplot3d: > Is it possible to change the axis lengths/aspect ratios independently? > > Richard > > Richard, Good question. I have never thought about such a feature for mplot3d. Looking back at the code, it does not appear to be feasible to do in its current state, as the code seems to assume that the 3d grid is a constructed from a unit cube. However, I will see if I can add aspect multipliers to the point calculation and get arbitrary aspects. Maybe I can get that feature added into the upcoming 1.1.0 release. Ben Root 
From: Benjamin Root <ben.root@ou...>  20110609 16:46:14
Attachments:
Message as HTML

On Thu, Jun 9, 2011 at 10:13 AM, Benjamin Root <ben.root@...> wrote: > > > On Thu, Jun 9, 2011 at 6:25 AM, Richard Hofmeister < > richard.hofmeister@...> wrote: > >> Hello mplot3d specialists, >> >> I would like to change the aspect ratio of the 3d axes similar to matlab's >> functionality with daspect() or the 'dataaspectratio' property of 3daxes. >> In the end, the xyplane should be nonsquare due to different lengths >> (not range) of the x and y axis (i know that i can use the aspect property >> of the axes to set the xz/yz aspect ratio). >> >> There is also the package "scitools", which provides all the matlab3d >> functions including daspect via a VTKbackend; that would be my next try. >> >> For the simple 3dplotting without fancy shading, i would like to stick to >> mplot3d: >> Is it possible to change the axis lengths/aspect ratios independently? >> >> Richard >> >> > Richard, > > Good question. I have never thought about such a feature for mplot3d. > Looking back at the code, it does not appear to be feasible to do in its > current state, as the code seems to assume that the 3d grid is a constructed > from a unit cube. However, I will see if I can add aspect multipliers to > the point calculation and get arbitrary aspects. Maybe I can get that > feature added into the upcoming 1.1.0 release. > > Ben Root > > Richard, I took a look at how this might be implemented. There would have to be some extra work to make the plots look right when experiencing changes in aspect. I first tried an implementation of just the plot box aspect ratio (pbaspect) as a member variable of the axes object. It will probably turn into a property so that I can link it with a daspect value. Also, the values should be normalized to 1, unless you want to see some interesting shrinkage/growth of your plot area. Try my branch here: https://github.com/WeatherGod/matplotlib/tree/mplot3d/pbaspect After building that branch, try the following script (shamelessly adapted from some Matlab help pages for pbaspect and daspect). import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D import numpy as np fig = plt.figure() ax = fig.gca(projection='3d') x, y = np.mgrid[2:2:.2, 2:2:.2] z = x * np.exp(x**2  y**2) ax.plot_surface(x, y, z, rstride=1, cstride=1) ax.pbaspect = [1.0, 1.0, 0.25] plt.show() While this will squash the zaxis nicely, it does not force the zticks to be pruned, so it gets a little ugly. However, the axis ticks can be changed manually. Also, with some of my other changes coming soon, it should be possible for the Axes3D object to automatically adjust the spacing of the tick labels so that it is not impacted by the changes in aspect ratio in the perpendicular direction (i.e.  the x and y tick labels are closer to the axis due to the zaxis scaling). Keep an eye on that branch as I work to improve this feature, and feel free to contribute to it as well! Ben Root 
From: Richard Hofmeister <richard.hofmeister@io...>  20110609 21:24:15
Attachments:
Message as HTML

Thanks a lot, Ben!!! With using the mplot3d/pbaspect branch, my plot shows exactly what i asked for a few hours(!) ago. Nothing ugly here :) I'll keep track of that branch and can at least contribute by testing. Richard 2011/6/9 Benjamin Root <ben.root@...> > > > On Thu, Jun 9, 2011 at 10:13 AM, Benjamin Root <ben.root@...> wrote: > >> >> >> On Thu, Jun 9, 2011 at 6:25 AM, Richard Hofmeister < >> richard.hofmeister@...> wrote: >> >>> Hello mplot3d specialists, >>> >>> I would like to change the aspect ratio of the 3d axes similar to >>> matlab's functionality with daspect() or the 'dataaspectratio' property of >>> 3daxes. >>> In the end, the xyplane should be nonsquare due to different lengths >>> (not range) of the x and y axis (i know that i can use the aspect property >>> of the axes to set the xz/yz aspect ratio). >>> >>> There is also the package "scitools", which provides all the matlab3d >>> functions including daspect via a VTKbackend; that would be my next try. >>> >>> For the simple 3dplotting without fancy shading, i would like to stick >>> to mplot3d: >>> Is it possible to change the axis lengths/aspect ratios independently? >>> >>> Richard >>> >>> >> Richard, >> >> Good question. I have never thought about such a feature for mplot3d. >> Looking back at the code, it does not appear to be feasible to do in its >> current state, as the code seems to assume that the 3d grid is a constructed >> from a unit cube. However, I will see if I can add aspect multipliers to >> the point calculation and get arbitrary aspects. Maybe I can get that >> feature added into the upcoming 1.1.0 release. >> >> Ben Root >> >> > Richard, > > I took a look at how this might be implemented. There would have to be > some extra work to make the plots look right when experiencing changes in > aspect. I first tried an implementation of just the plot box aspect ratio > (pbaspect) as a member variable of the axes object. It will probably turn > into a property so that I can link it with a daspect value. Also, the > values should be normalized to 1, unless you want to see some interesting > shrinkage/growth of your plot area. > > Try my branch here: > https://github.com/WeatherGod/matplotlib/tree/mplot3d/pbaspect > > After building that branch, try the following script (shamelessly adapted > from some Matlab help pages for pbaspect and daspect). > > import matplotlib.pyplot as plt > from mpl_toolkits.mplot3d import Axes3D > import numpy as np > > fig = plt.figure() > ax = fig.gca(projection='3d') > > x, y = np.mgrid[2:2:.2, 2:2:.2] > z = x * np.exp(x**2  y**2) > ax.plot_surface(x, y, z, rstride=1, cstride=1) > ax.pbaspect = [1.0, 1.0, 0.25] > plt.show() > > While this will squash the zaxis nicely, it does not force the zticks to > be pruned, so it gets a little ugly. However, the axis ticks can be changed > manually. Also, with some of my other changes coming soon, it should be > possible for the Axes3D object to automatically adjust the spacing of the > tick labels so that it is not impacted by the changes in aspect ratio in the > perpendicular direction (i.e.  the x and y tick labels are closer to the > axis due to the zaxis scaling). > > Keep an eye on that branch as I work to improve this feature, and feel free > to contribute to it as well! > > Ben Root > 