Mercurial > octave
changeset 21808:a4c744194bbb
Add equal data aspect ratio to gnuplot graphics toolkit 3D plots (bug #47974).
* axis.m: Clarify meaning of 'square' and 'equal' in documentation. Remove
gnuplot-specific FIXME.
* __gnuplot_draw_axes__.m: Remove line of cruft for sz_str. If the plot is 3D
and data aspect ratio is equal in at least x-y dimensions, then set view
equal.
author | Daniel J Sebald <daniel.sebald@ieee.org> |
---|---|
date | Thu, 02 Jun 2016 11:06:56 -0500 |
parents | 1955af16b42e |
children | b2f1f4cf1389 |
files | scripts/plot/appearance/axis.m scripts/plot/util/private/__gnuplot_draw_axes__.m |
diffstat | 2 files changed, 15 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/plot/appearance/axis.m Thu Jun 02 10:02:34 2016 -0700 +++ b/scripts/plot/appearance/axis.m Thu Jun 02 11:06:56 2016 -0500 @@ -61,10 +61,10 @@ ## ## @table @asis ## @item @qcode{"square"} -## Force a square aspect ratio. +## Force a square axis aspect ratio. ## ## @item @qcode{"equal"} -## Force x distance to equal y-distance. +## Force x-axis unit distance to equal y-axis (and z-axis) unit distance. ## ## @item @qcode{"normal"} ## Restore default aspect ratio. @@ -191,14 +191,6 @@ set (ca, "dataaspectratiomode", "auto", "plotboxaspectratio", [1, 1, 1]); elseif (strcmp (ax, "equal")) - if (strcmp (get (ancestor (ca, "figure"), "__graphics_toolkit__"), "gnuplot")) - ## FIXME: gnuplot applies the aspect ratio activepostionproperty. - set (ca, "activepositionproperty", "position"); - ## The following line is a trick used to trigger the recalculation of - ## aspect related magnitudes even if the aspect ratio is the same - ## (useful with the x11 gnuplot terminal after a window resize) - set (ca, "dataaspectratiomode", "auto"); - endif set (ca, "dataaspectratio", [1, 1, 1], "plotboxaspectratio", [5 4 4]); elseif (strcmpi (ax, "normal"))
--- a/scripts/plot/util/private/__gnuplot_draw_axes__.m Thu Jun 02 10:02:34 2016 -0700 +++ b/scripts/plot/util/private/__gnuplot_draw_axes__.m Thu Jun 02 11:06:56 2016 -0500 @@ -126,7 +126,6 @@ fprintf (plot_stream, "unset lmargin;\n"); fprintf (plot_stream, "unset rmargin;\n"); fprintf (plot_stream, "set origin %g, %g;\n", pos(1:2)); - sz_str = ""; if (strcmpi (axis_obj.dataaspectratiomode, "manual")) sz_str = sprintf ("ratio %g", -dr); else @@ -138,6 +137,19 @@ fputs (plot_stream, sz_str); endif + ## Code above uses axis size for the data aspect ratio, which isn't + ## quite correct. The only fine control is to set all axes units equal. + if (nd == 3 && + strcmpi (axis_obj.dataaspectratiomode, "manual") && + axis_obj.dataaspectratio(1) == axis_obj.dataaspectratio(2)) + if (axis_obj.dataaspectratio(1) == axis_obj.dataaspectratio(3)) + zstr = "z"; + else + zstr = ""; + endif + fprintf (plot_stream, "set view equal xy%s;\n", zstr); + endif + ## Reset all labels, axis-labels, tick-labels, and title ## FIXME: We should have an function to initialize the axis. ## Presently, this is dispersed in this function.