Discussion:
axis equal help!
pvfloripa
2009-08-05 23:40:05 UTC
Permalink
Hi Everybody,

I am trying to plot a 3-D plot from several points. However, when I use the
"axis equal" command, only the X and Y axis are set to the same scale,
whereas Z doesn't change, making the plot look wrong. Is there any way
around this?

The same code works fine in Matlab.

Many thanks!

Paulo
--
View this message in context: http://www.nabble.com/axis-equal-help%21-tp24838073p24838073.html
Sent from the Octave - General mailing list archive at Nabble.com.
Ben Abbott
2009-08-06 00:04:44 UTC
Permalink
Post by pvfloripa
Hi Everybody,
I am trying to plot a 3-D plot from several points. However, when I use the
"axis equal" command, only the X and Y axis are set to the same scale,
whereas Z doesn't change, making the plot look wrong. Is there any way
around this?
The same code works fine in Matlab.
Many thanks!
Paulo
Something like the following should work ...

figure (1)
clf
surf (peaks)
axis auto
xl = get (gca, "xlim");
yl = get (gca, "ylim");
zl = get (gca, "zlim");
span = max ([diff(xl), diff(yl), diff(zl)]);
xlim (mean (xl) + span*[-0.5, 0.5])
ylim (mean (yl) + span*[-0.5, 0.5])
zlim (mean (zl) + span*[-0.5, 0.5])

Ben
John W. Eaton
2009-08-06 00:28:30 UTC
Permalink
On 5-Aug-2009, Ben Abbott wrote:

| On Aug 5, 2009, at 7:40 PM, pvfloripa wrote:
|
| > Hi Everybody,
| >
| > I am trying to plot a 3-D plot from several points. However, when I
| > use the
| > "axis equal" command, only the X and Y axis are set to the same scale,
| > whereas Z doesn't change, making the plot look wrong. Is there any way
| > around this?
| >
| > The same code works fine in Matlab.
| >
| > Many thanks!
| >
| > Paulo
|
| Something like the following should work ...
|
| figure (1)
| clf
| surf (peaks)
| axis auto
| xl = get (gca, "xlim");
| yl = get (gca, "ylim");
| zl = get (gca, "zlim");
| span = max ([diff(xl), diff(yl), diff(zl)]);
| xlim (mean (xl) + span*[-0.5, 0.5])
| ylim (mean (yl) + span*[-0.5, 0.5])
| zlim (mean (zl) + span*[-0.5, 0.5])

Does 3d plotting in gnuplot have a way to specify equal axes? The
docs for the version I have (4.2.5) say that "set size ratio" has no
effect for 3d plots, and that's what we are currently using to get
equal axes.

jwe
Ben Abbott
2009-08-06 01:57:57 UTC
Permalink
Post by John W. Eaton
|
| > Hi Everybody,
| >
| > I am trying to plot a 3-D plot from several points. However, when I
| > use the
| > "axis equal" command, only the X and Y axis are set to the same scale,
| > whereas Z doesn't change, making the plot look wrong. Is there any way
| > around this?
| >
| > The same code works fine in Matlab.
| >
| > Many thanks!
| >
| > Paulo
|
| Something like the following should work ...
|
| figure (1)
| clf
| surf (peaks)
| axis auto
| xl = get (gca, "xlim");
| yl = get (gca, "ylim");
| zl = get (gca, "zlim");
| span = max ([diff(xl), diff(yl), diff(zl)]);
| xlim (mean (xl) + span*[-0.5, 0.5])
| ylim (mean (yl) + span*[-0.5, 0.5])
| zlim (mean (zl) + span*[-0.5, 0.5])
Does 3d plotting in gnuplot have a way to specify equal axes? The
docs for the version I have (4.2.5) say that "set size ratio" has no
effect for 3d plots, and that's what we are currently using to get
equal axes.
jwe
I think there is a simple fix for gnuplot >4.3 (using the approach I
outlined above). I haven't looked into the older gnuplot yet.

However, I noticed that demo("axis",6) produces an error.

I don't have the time to dig into that right now.

Ben
John W. Eaton
2009-08-06 02:26:10 UTC
Permalink
On 5-Aug-2009, Ben Abbott wrote:

| I think there is a simple fix for gnuplot >4.3 (using the approach I
| outlined above). I haven't looked into the older gnuplot yet.
|
| However, I noticed that demo("axis",6) produces an error.

I don't see an error message and the plot it generates looks OK to
me (but maybe it is wrong and I don't understand how the plot is
intended to appear). What is the problem you see?

jwe
pvfloripa
2009-08-06 03:55:35 UTC
Permalink
Hi all,

Thanks for all your replies.
The problem I see is that, say I have 3 line segments that form the sketch
of a door, defined by 6 points:

point1 = [ 0 0 0]
point2 = [ 0 0 2]

point3 = [ 0 0 2]
point4 = [ 1 0 2]

point5 = [ 1 0 2]
point6 = [ 1 0 0]

which correspond to the sides (points 1,2 and 5,6) and the top ( points 3,4)
of the door.
Instead of seeing the door in the correct proportion (ie, the height 2x the
width), I see a very tall and very thin door.

I will try the solutions suggested and let you know.

Thanks again,

Paulo
Post by John W. Eaton
| I think there is a simple fix for gnuplot >4.3 (using the approach I
| outlined above). I haven't looked into the older gnuplot yet.
|
| However, I noticed that demo("axis",6) produces an error.
I don't see an error message and the plot it generates looks OK to
me (but maybe it is wrong and I don't understand how the plot is
intended to appear). What is the problem you see?
jwe
_______________________________________________
Help-octave mailing list
https://www-old.cae.wisc.edu/mailman/listinfo/help-octave
--
View this message in context: http://www.nabble.com/axis-equal-help%21-tp24838073p24840038.html
Sent from the Octave - General mailing list archive at Nabble.com.
Ben Abbott
2009-08-06 12:03:26 UTC
Permalink
Post by John W. Eaton
| I think there is a simple fix for gnuplot >4.3 (using the approach I
| outlined above). I haven't looked into the older gnuplot yet.
|
| However, I noticed that demo("axis",6) produces an error.
I don't see an error message and the plot it generates looks OK to
me (but maybe it is wrong and I don't understand how the plot is
intended to appear). What is the problem you see?
jwe
You are correct. I deleted my axis.m and pulled a fresh copy, and the
error is gone.

Ben
pathematica
2010-07-13 21:14:56 UTC
Permalink
Dear John and others

First, thanks for the great program - it is an exemplar in the open source
world.

I am also having problems plotting vectors in 3d space.

The fix you suggest given above frames particular plots symmetrically about
their global extrema but that is not the problem. I need to create a
symmetrical convex hull into which I can plot vectors. I can specify the
same range for each of the axes to create the necessary octant in the 3d
orthonormal vector space. It is straightforward to force the xy aspect
square but the z axis remains persistently foreshortened despite trying a
number of fixes (including those on this particular thread). It is worth
emphasising that I am creating a vector space in which to show shapes rather
than a function of two variables in which the xy plane specifies the
arguments of the function.

I am using Octave and gnuplot under ubuntu 10.04.
Ubuntu supplies octave 3.2.3 and gnuplot 4.2.6-1 from its repositories.
Following a hint given above, I manually upgraded gnuplot to version 4.4 but
this did not help.
I have tried several other fixes (from this and other sources) but none seem
to work.
I have read the manual, honest!

Any help would be gratefully received.

-----------------------------------------------------------------
Background (included in case it might be helpful but appended after the
description of the problem in case it is not).

I am trying to create a computer aided learning package which appeals to the
geometry of a particular process (rather than to the algebra). For this to
make sense, I require a 1:1:1 aspect ratio for the plot3 output.

I have given a live presentation which worked well. The plots were generated
live during the presentation (to show I was not cheating). I manually
resized the height of the X windows generated by gnuplot to create the
required 1:1:1 aspect ratio visually.

I am trying to create a package that others could use unsupervised. Of
course, it would be possible to give instructions on how to resize the
gnuplot output X-windows manually (as I did in the live presentation) but
that would not be elegant (and it might appear to be a cheat to the
mathematically unsophisticated, which is the target audience and the reason
why I am appealing to geometry).

I also want to create a publication using the images. Plotting to files
(rather than to the screen) produces rectangular cuboids (ie square prisms
foreshortened on the z axis) rather than cubes (as you would know, even if
the windows are resized beforehand). I can post process the images with eg
GIMP for this but as the text is scaled (as well as the plots) this method
is not ideal.

I was hoping the computer aided package and the publication might be a
showcase of what can be achieved with open source software.

PS did I say "thanks for the program"? It bears repeating!
--
View this message in context: http://octave.1599824.n4.nabble.com/axis-equal-help-tp1636701p2288007.html
Sent from the Octave - General mailing list archive at Nabble.com.
Ben Abbott
2010-07-13 23:00:11 UTC
Permalink
Post by pathematica
Dear John and others
First, thanks for the great program - it is an exemplar in the open source
world.
I am also having problems plotting vectors in 3d space.
The fix you suggest given above frames particular plots symmetrically about
their global extrema but that is not the problem. I need to create a
symmetrical convex hull into which I can plot vectors. I can specify the
same range for each of the axes to create the necessary octant in the 3d
orthonormal vector space. It is straightforward to force the xy aspect
square but the z axis remains persistently foreshortened despite trying a
number of fixes (including those on this particular thread). It is worth
emphasising that I am creating a vector space in which to show shapes rather
than a function of two variables in which the xy plane specifies the
arguments of the function.
I am using Octave and gnuplot under ubuntu 10.04.
Ubuntu supplies octave 3.2.3 and gnuplot 4.2.6-1 from its repositories.
Following a hint given above, I manually upgraded gnuplot to version 4.4 but
this did not help.
I have tried several other fixes (from this and other sources) but none seem
to work.
I have read the manual, honest!
Any help would be gratefully received.
If I understand what you're trying to do, the problem is having the pixels/data appear to be the same for each axis, correct?

Octave currently doesn't have a way of doing this in an automated way for 3D.

You can tweak the plot to produce the desired effect by changing its vertical size. For output produced by print(), change the figure's 4th value of the paperposition property. For the plot displayed in the window, change the 4th value of the figure's position property.

Ben
pathematica
2010-07-13 23:32:32 UTC
Permalink
Post by Ben Abbott
If I understand what you're trying to do, the problem is having the
pixels/data appear to be the same for each axis, correct?
Octave currently doesn't have a way of doing this in an automated way for 3D.
You can tweak the plot to produce the desired effect by changing its
vertical size. For output produced by print(), change the figure's 4th
value of the paperposition property. For the plot displayed in the window,
change the 4th value of the figure's position property.
Ben
_______________________________________________
Help-octave mailing list
https://www-old.cae.wisc.edu/mailman/listinfo/help-octave
Hi Ben

Thanks, that helped.

In case others have the same problem and want the details, I will report the
results of making changes based on your advice (for others, not for you!)

Using
Post by Ben Abbott
get(gca())
I found a parameter called "position" (rather than "paperposition") which is
a 4-vector which was reported as

{
...
position =

0.13000 0.11000 0.77500 0.81500
...
}

By experimentation, I note that
* the first component determines the leftmost position of the plot
* the second component determines the position of the bottom of the plot
* the third value determines the rightmost position (so I guess it might be
absolute position or the offset from the first component)
* the fourth value determines the position of the top of the plot (ie the
absolute or the offset from the second)

As noted, the original values are shown above

I note that changing them resizes the plot in the X window but the size of
the window is unchanged.

I found that changing the fourth value did stretch the z axis as required
but the top of the plot was lost at the top of the window so I had to reduce
the second component (I guess I might have squashed the first and third
instead)

The values that worked were set as and are as follows (note the changed
second and fourth components, and also that it accepted a negative value)
Post by Ben Abbott
set (gca (), "position", [0.13000 -0.05000 0.77500 1.08000])
I presume the same things will happen if I plot to a file.

Thanks again and I apologise in advance if I have transcribed anything
incorrectly (I won't be able to edit!).
--
View this message in context: http://octave.1599824.n4.nabble.com/axis-equal-help-tp1636701p2288113.html
Sent from the Octave - General mailing list archive at Nabble.com.
Ben Abbott
2010-07-13 23:47:49 UTC
Permalink
Post by pathematica
Post by Ben Abbott
If I understand what you're trying to do, the problem is having the
pixels/data appear to be the same for each axis, correct?
Octave currently doesn't have a way of doing this in an automated way for 3D.
You can tweak the plot to produce the desired effect by changing its
vertical size. For output produced by print(), change the figure's 4th
value of the paperposition property. For the plot displayed in the window,
change the 4th value of the figure's position property.
Ben
Hi Ben
Thanks, that helped.
In case others have the same problem and want the details, I will report the
results of making changes based on your advice (for others, not for you!)
Using
Post by Ben Abbott
get(gca())
I found a parameter called "position" (rather than "paperposition") which is
a 4-vector which was reported as
Changing the axis "position" property will work. What I had suggested was to change the *figure*'s "paperposition" property.

You'll see this property listed if you type "get (gcf ())"

Ben
pathematica
2010-07-14 00:03:35 UTC
Permalink
Post by Ben Abbott
Changing the axis "position" property will work. What I had suggested was
to change the *figure*'s "paperposition" property.
You'll see this property listed if you type "get (gcf ())"
Ben
Hi Ben (again!)

I was not able to make that work. I interrogated the graphic object (here,
Post by Ben Abbott
figure(2); get (gcf (), "paperposition")
ans =

0.25000 2.50000 8.00000 6.00000
Post by Ben Abbott
figure(2); set (gcf (), "paperposition", [0.25000 2.50000 8.00000
9.00000])
(changed fourth component)

but that had no effect. Would this be expected of an X-window and is it the
correct way when I write the plot to a file (which I have not tried yet)?

Thanks
--
View this message in context: http://octave.1599824.n4.nabble.com/axis-equal-help-tp1636701p2288133.html
Sent from the Octave - General mailing list archive at Nabble.com.
Ben Abbott
2010-07-14 00:25:11 UTC
Permalink
Post by pathematica
Post by Ben Abbott
Changing the axis "position" property will work. What I had suggested was
to change the *figure*'s "paperposition" property.
You'll see this property listed if you type "get (gcf ())"
Ben
Hi Ben (again!)
I was not able to make that work. I interrogated the graphic object (here,
Post by Ben Abbott
figure(2); get (gcf (), "paperposition")
ans =
0.25000 2.50000 8.00000 6.00000
Post by Ben Abbott
figure(2); set (gcf (), "paperposition", [0.25000 2.50000 8.00000
9.00000])
(changed fourth component)
but that had no effect. Would this be expected of an X-window and is it the
correct way when I write the plot to a file (which I have not tried yet)?
Thanks
As I had indicated ealier the "paperposition" property will change the result of the print() command. To change the displayed result you need to modify the "positon" property. When using the default gnuplot backend, this requires you set the property when the window is created.

figure ('position', position)

Where the variable "position" contains the 1x4 vector for the figure's position in pixels.

Ben
pathematica
2010-07-14 00:50:39 UTC
Permalink
Thanks, Ben

You have given me the means to solve both problems. I will experiment
further to assimilate.

Very helpful, thank you.
--
View this message in context: http://octave.1599824.n4.nabble.com/axis-equal-help-tp1636701p2288174.html
Sent from the Octave - General mailing list archive at Nabble.com.
Loading...