Mercurial > hg > octave-avbm
changeset 10532:568c7c041fac
colorbar.m: Consistent treatment of plotboxaspectratio. Add listener for plotboxaspectratiomode.
author | Ben Abbott <bpabbott@mac.com> |
---|---|
date | Mon, 19 Apr 2010 07:22:30 -0400 |
parents | 2dd8ea8bfd71 |
children | f094ac9bc93e |
files | scripts/ChangeLog scripts/plot/__go_draw_axes__.m scripts/plot/axis.m scripts/plot/colorbar.m |
diffstat | 4 files changed, 37 insertions(+), 56 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,10 @@ +2010-04-19 Ben Abbott <bpabbott@mac.com> + + * /plot/colorbar.m: Consistent treatment of plotboxaspectratio, and + add listener for plotboxaspectratiomode. + * /plot/axis.m: Consistent treatment of plotboxaspectratio. + * /plot/__go_draw_axes__.m: Consistently determine axes position. + 2010-04-17 Ben Abbott <bpabbott@mac.com> * plot/private/__actual_axis_position__.m: Fix bug when restoring
--- a/scripts/plot/__go_draw_axes__.m +++ b/scripts/plot/__go_draw_axes__.m @@ -46,12 +46,13 @@ endif nd = __calc_dimensions__ (axis_obj); - pos = axis_obj.position; - pos = pos - implicit_margin([1, 2, 1, 2]).*[1, 1, -0.5, -0.5]; + if (strcmpi (axis_obj.plotboxaspectratiomode, "manual")) + pos = __actual_axis_position__ (axis_obj); + else + pos = axis_obj.position; + pos = pos - implicit_margin([1, 2, 1, 2]).*[1, 1, -0.5, -0.5]; + endif if (__gnuplot_has_feature__ ("screen_coordinates_for_{lrtb}margin")) - if (strcmpi (axis_obj.plotboxaspectratiomode, "manual")) - pos = __actual_axis_position__ (axis_obj); - endif if (nd == 2) x = [1, 1]; else @@ -72,8 +73,8 @@ fprintf (plot_stream, "set origin %.15g, %.15g;\n", pos(1), pos(2)); fprintf (plot_stream, "set size %.15g, %.15g;\n", pos(3), pos(4)); - if (strcmpi (axis_obj.plotboxaspectratiomode, "manual")) - r = axis_obj.plotboxaspectratio; + if (strcmpi (axis_obj.dataaspectratiomode, "manual")) + r = axis_obj.dataaspectratio; fprintf (plot_stream, "set size ratio %.15g;\n", -r(2)/r(1)); else fputs (plot_stream, "set size noratio;\n");
--- a/scripts/plot/axis.m +++ b/scripts/plot/axis.m @@ -164,21 +164,11 @@ __axis__ (ca, "equal") __do_tight_option__ (ca); elseif (strcmpi (ax, "square")) - if (__gnuplot_has_feature__ ("screen_coordinates_for_{lrtb}margin")) - set (ca, "plotboxaspectratio", [1, 1, 1]); - else - x = xlim; - y = ylim; - set (ca, "plotboxaspectratio", [(y(2)-y(1)), (x(2)-x(1)), 1]); - endif + set (ca, "plotboxaspectratio", [1, 1, 1]); elseif (strcmp (ax, "equal")) - if (__gnuplot_has_feature__ ("screen_coordinates_for_{lrtb}margin")) - x = xlim; - y = ylim; - set (ca, "plotboxaspectratio", [(x(2)-x(1)), (y(2)-y(1)), 1]); - else - set (ca, "plotboxaspectratio", [1, 1, 1]); - endif + x = xlim; + y = ylim; + set (ca, "plotboxaspectratio", [(x(2)-x(1)), (y(2)-y(1)), 1]); elseif (strcmpi (ax, "normal")) set (ca, "plotboxaspectratiomode", "auto");
--- a/scripts/plot/colorbar.m +++ b/scripts/plot/colorbar.m @@ -108,7 +108,7 @@ orig_pos = obj.position; orig_opos = obj.outerposition; - [pos, cpos, vertical, mirror, aspect] = ... + [pos, cpos, vertical, mirror] = ... __position_colorbox__ (loc, obj, ancestor (ax, "figure")); set (ax, "activepositionproperty", "position", "position", pos); @@ -145,10 +145,6 @@ endif endif - if (! isnan (aspect)) - set (cax, "plotboxaspectratio", aspect); - endif - ctext = text (0, 0, "", "tag", "colorbar","visible", "off", "handlevisibility", "off", "xliminclude", "off", "yliminclude", "off", "zliminclude", "off", @@ -158,6 +154,7 @@ addlistener (ax, "clim", {@update_colorbar_clim, hi, vertical}) addlistener (ax, "plotboxaspectratio", {@update_colorbar_axis, cax}) + addlistener (ax, "plotboxaspectratiomode", {@update_colorbar_axis, cax}) addlistener (ax, "position", {@update_colorbar_axis, cax}) endif @@ -214,7 +211,7 @@ (isempty (gcbf()) || strcmp (get (gcbf(), "beingdeleted"),"off"))) loc = get (cax, "location"); obj = get (h); - [pos, cpos, vertical, mirror, aspect] = ... + [pos, cpos, vertical, mirror] = ... __position_colorbox__ (loc, obj, ancestor (h, "figure")); if (vertical) @@ -235,13 +232,10 @@ endif endif - if (! isnan (aspect)) - set (cax, "plotboxaspectratio", aspect); - endif endif endfunction -function [pos, cpos, vertical, mirr, aspect] = __position_colorbox__ (cbox, obj, cf) +function [pos, cpos, vertical, mirr] = __position_colorbox__ (cbox, obj, cf) pos = obj.position; sz = pos(3:4); @@ -325,33 +319,22 @@ cpos = [origin, sz]; if (strcmpi (obj.plotboxaspectratiomode, "manual")) - if (__gnuplot_has_feature__ ("screen_coordinates_for_{lrtb}margin")) - obj.position = pos; - actual_pos = __actual_axis_position__ (obj); - if (strfind (cbox, "outside")) - scale = 1.0; - else - scale = 0.9; - endif - if (sz(1) > sz(2)) - dx = (1-scale)*actual_pos(3); - cpos(1) = actual_pos(1) + dx/2; - cpos(3) = actual_pos(3) - dx; - else - dy = (1-scale)*actual_pos(4); - cpos(2) = actual_pos(2) + dy/2; - cpos(4) = actual_pos(4) - dy; - endif - aspect = NaN; + obj.position = pos; + actual_pos = __actual_axis_position__ (obj); + if (strfind (cbox, "outside")) + scale = 1.0; else - if (vertical) - aspect = [1, 0.21, 1]; - else - aspect = [0.21, 1, 1]; - endif + scale = 0.9; endif - else - aspect = NaN; + if (sz(1) > sz(2)) + dx = (1-scale)*actual_pos(3); + cpos(1) = actual_pos(1) + dx/2; + cpos(3) = actual_pos(3) - dx; + else + dy = (1-scale)*actual_pos(4); + cpos(2) = actual_pos(2) + dy/2; + cpos(4) = actual_pos(4) - dy; + endif endif endfunction