Richard Hofmeister | 9 Jun 13:25 2011
Picon

mplot3d and daspect

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 3d-axes.
In the end, the x-y-plane should be non-square 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 x-z/y-z aspect ratio).

There is also the package "scitools", which provides all the matlab-3d functions including daspect via a VTK-backend; that would be my next try.

For the simple 3d-plotting without fancy shading, i would like to stick to mplot3d:
Is it possible to change the axis lengths/aspect ratios independently?

Richard

------------------------------------------------------------------------------
EditLive Enterprise is the world's most technically advanced content
authoring tool. Experience the power of Track Changes, Inline Image
Editing and ensure content is compliant with Accessibility Checking.
http://p.sf.net/sfu/ephox-dev2dev
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@...
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Benjamin Root | 9 Jun 17:13 2011
Picon

Re: mplot3d and daspect



On Thu, Jun 9, 2011 at 6:25 AM, Richard Hofmeister <richard.hofmeister-3jVuOyHyqGOMbxhyh7iT0rNAH6kLmebB@public.gmane.org> 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 3d-axes.
In the end, the x-y-plane should be non-square 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 x-z/y-z aspect ratio).

There is also the package "scitools", which provides all the matlab-3d functions including daspect via a VTK-backend; that would be my next try.

For the simple 3d-plotting 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

------------------------------------------------------------------------------
EditLive Enterprise is the world's most technically advanced content
authoring tool. Experience the power of Track Changes, Inline Image
Editing and ensure content is compliant with Accessibility Checking.
http://p.sf.net/sfu/ephox-dev2dev
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@...
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Benjamin Root | 9 Jun 18:41 2011
Picon

Re: mplot3d and daspect



On Thu, Jun 9, 2011 at 10:13 AM, Benjamin Root <ben.root <at> ou.edu> wrote:


On Thu, Jun 9, 2011 at 6:25 AM, Richard Hofmeister <richard.hofmeister-3jVuOyHyqGOMbxhyh7iT0rNAH6kLmebB@public.gmane.org> 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 3d-axes.
In the end, the x-y-plane should be non-square 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 x-z/y-z aspect ratio).

There is also the package "scitools", which provides all the matlab-3d functions including daspect via a VTK-backend; that would be my next try.

For the simple 3d-plotting 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 z-axis nicely, it does not force the z-ticks 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 z-axis 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
------------------------------------------------------------------------------
EditLive Enterprise is the world's most technically advanced content
authoring tool. Experience the power of Track Changes, Inline Image
Editing and ensure content is compliant with Accessibility Checking.
http://p.sf.net/sfu/ephox-dev2dev
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@...
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Richard Hofmeister | 9 Jun 23:24 2011
Picon

Re: mplot3d and daspect

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-GrrYUJ3DTa8@public.gmane.org>


On Thu, Jun 9, 2011 at 10:13 AM, Benjamin Root <ben.root-GrrYUJ3DTa8@public.gmane.org> wrote:


On Thu, Jun 9, 2011 at 6:25 AM, Richard Hofmeister <richard.hofmeister <at> io-warnemuende.de> 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 3d-axes.
In the end, the x-y-plane should be non-square 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 x-z/y-z aspect ratio).

There is also the package "scitools", which provides all the matlab-3d functions including daspect via a VTK-backend; that would be my next try.

For the simple 3d-plotting 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 z-axis nicely, it does not force the z-ticks 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 z-axis 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

------------------------------------------------------------------------------
EditLive Enterprise is the world's most technically advanced content
authoring tool. Experience the power of Track Changes, Inline Image
Editing and ensure content is compliant with Accessibility Checking.
http://p.sf.net/sfu/ephox-dev2dev
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@...
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Alexandr | 2 Nov 08:18 2012
Picon

Re: mplot3d and daspect

Benjamin Root <ben.root <at> ...> writes:

> 
> 
> On Thu, Jun 9, 2011 at 10:13 AM, Benjamin Root <ben.root <at> ou.edu> wrote:
> 
> 
> 
> 
> On Thu, Jun 9, 2011 at 6:25 AM, Richard Hofmeister <richard.hofmeister-
3jVuOyHyqGOMbxhyh7iT0rNAH6kLmebB <at> public.gmane.org> 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 3d-axes.In the end, the x-y-plane should be non-square 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 x-z/y-z aspect ratio).There is also the 
package "scitools", which provides all the matlab-3d functions including daspect 
via a VTK-backend; that would be my next try.For the simple 3d-plotting 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/pbaspectAfter building 
that branch, try the following script (shamelessly adapted from some Matlab help 
pages for pbaspect and daspect).import matplotlib.pyplot as pltfrom 
mpl_toolkits.mplot3d import Axes3Dimport numpy as npfig = 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 z-axis nicely, it does not force the 
z-ticks 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 z-axis 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
> 
> 
> ------------------------------------------------------------------------------
> EditLive Enterprise is the world's most technically advanced content
> authoring tool. Experience the power of Track Changes, Inline Image
> Editing and ensure content is compliant with Accessibility Checking.
> http://p.sf.net/sfu/ephox-dev2dev
> 
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users <at> ...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> 

Hello!

I am looking for a tool like pbaspect. The only question is how to implement it 
into matplotlib? Do you have a step by step instruction?

Thank you.
Regards,
Alexandr

------------------------------------------------------------------------------
LogMeIn Central: Instant, anywhere, Remote PC access and management.
Stay in control, update software, and manage PCs from one command center
Diagnose problems and improve visibility into emerging IT issues
Automate, monitor and manage. Do more in less time with Central
http://p.sf.net/sfu/logmein12331_d2d
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Benjamin Root | 2 Nov 16:44 2012
Picon

Re: mplot3d and daspect



On Fri, Nov 2, 2012 at 3:18 AM, Alexandr <o.pischanskyy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
Benjamin Root <ben.root <at> ...> writes:

>
>
> On Thu, Jun 9, 2011 at 10:13 AM, Benjamin Root <ben.root <at> ou.edu> wrote:
>
>
>
>
> On Thu, Jun 9, 2011 at 6:25 AM, Richard Hofmeister <richard.hofmeister-
3jVuOyHyqGOMbxhyh7iT0rNAH6kLmebB-XMD5yJDbdMReXY1tMh2IBg@public.gmane.org> 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 3d-axes.In the end, the x-y-plane should be non-square 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 x-z/y-z aspect ratio).There is also the
package "scitools", which provides all the matlab-3d functions including daspect
via a VTK-backend; that would be my next try.For the simple 3d-plotting 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/pbaspectAfter building
that branch, try the following script (shamelessly adapted from some Matlab help
pages for pbaspect and daspect).import matplotlib.pyplot as pltfrom
mpl_toolkits.mplot3d import Axes3Dimport numpy as npfig = 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 z-axis nicely, it does not force the
z-ticks 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 z-axis 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
>
>
> ------------------------------------------------------------------------------
> EditLive Enterprise is the world's most technically advanced content
> authoring tool. Experience the power of Track Changes, Inline Image
> Editing and ensure content is compliant with Accessibility Checking.
> http://p.sf.net/sfu/ephox-dev2dev
>
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users <at> ...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>


Hello!

I am looking for a tool like pbaspect. The only question is how to implement it
into matplotlib? Do you have a step by step instruction?

Thank you.
Regards,
Alexandr


I guess there has been enough interest in this feature that I probably should devote some time to correctly implementing it.  I'll see what I can do!

Ben Root

------------------------------------------------------------------------------
LogMeIn Central: Instant, anywhere, Remote PC access and management.
Stay in control, update software, and manage PCs from one command center
Diagnose problems and improve visibility into emerging IT issues
Automate, monitor and manage. Do more in less time with Central
http://p.sf.net/sfu/logmein12331_d2d
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@...
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Gmane