Mercurial > hg > octave-lojdl
changeset 9281:02b16eeb3167
Fix yticklabels for log scale colorbar.
author | Ben Abbott <bpabbott@mac.com> |
---|---|
date | Thu, 28 May 2009 06:21:01 -0400 |
parents | 40fb718a2e67 |
children | 2ed8d2d92507 |
files | scripts/ChangeLog scripts/plot/__go_draw_axes__.m scripts/plot/__go_draw_figure__.m scripts/plot/colorbar.m |
diffstat | 4 files changed, 37 insertions(+), 19 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,11 @@ +2009-05-28 Ben Abbott <bpabbott@mac.com> + + * plot/__go_draw_axes__.m: Set x2range when xaxislocation=='top' and set + y2range when yaxislocation=='right'. Simplified support for ticklabel + separator '|'. + * plot/__go_draw_figure__.m: Change 'autoscale fix' to 'autoscale keepfix'. + * plot/colorbar.m: Add demos. + 2009-05-28 Ben Abbott <bpabbott@mac.com> * plot/__go_draw_axes__.m: Add support for ticklabel separator '|'.
--- a/scripts/plot/__go_draw_axes__.m +++ b/scripts/plot/__go_draw_axes__.m @@ -1065,6 +1065,9 @@ xdir = "noreverse"; endif fprintf (plot_stream, "set xrange [%.15e:%.15e] %s;\n", xlim, xdir); + if (strcmpi (axis_obj.xaxislocation, "top")) + fprintf (plot_stream, "set x2range [%.15e:%.15e] %s;\n", xlim, xdir); + endif if (isempty (ylim)) return; @@ -1075,6 +1078,9 @@ ydir = "noreverse"; endif fprintf (plot_stream, "set yrange [%.15e:%.15e] %s;\n", ylim, ydir); + if (strcmpi (axis_obj.yaxislocation, "right")) + fprintf (plot_stream, "set y2range [%.15e:%.15e] %s;\n", ylim, ydir); + endif if (nd == 3) if (isempty (zlim)) @@ -1685,7 +1691,7 @@ endif endfunction -function newlabel = ticklabel_to_cell (ticklabel) +function ticklabel = ticklabel_to_cell (ticklabel) if (! isempty (ticklabel) && ! iscell (ticklabel)) if (isnumeric (ticklabel)) ## Use upto 5 significant digits @@ -1693,26 +1699,12 @@ endif n = setdiff (findstr (ticklabel, '|'), findstr (ticklabel, '\|')); if (! isempty (n)) - ## FIXME - Can regexp() do this easier? - if (ticklabel(1) != "|") - n = unique ([n, 0]); - endif - if (ticklabel(end) != "|") - n = unique ([n, numel(ticklabel)+1]); - endif - n1 = n + 1; - n1 = n1(n1<numel(ticklabel)) - n2 = n - 1; - n2 = n2(n2>0) - newlabel = cell (numel(n2), 1); - for n = 1:numel(newlabel) - newlabel{n} = ticklabel(n1(n):n2(n)); - endfor + ticklabel = strsplit (ticklabel, "|"); else - newlabel = cellstr (ticklabel); + ticklabel = cellstr (ticklabel); endif else - newlabel = ticklabel; + ticklabel = ticklabel; endif endfunction
--- a/scripts/plot/__go_draw_figure__.m +++ b/scripts/plot/__go_draw_figure__.m @@ -59,7 +59,7 @@ if (nkids > 0) fputs (plot_stream, "\nreset;\n"); - fputs (plot_stream, "set autoscale fix;\n"); + fputs (plot_stream, "set autoscale keepfix;\n"); fputs (plot_stream, "set multiplot;\n"); fputs (plot_stream, "set origin 0, 0\n"); fputs (plot_stream, "set size 1, 1\n");
--- a/scripts/plot/colorbar.m +++ b/scripts/plot/colorbar.m @@ -382,6 +382,11 @@ %!demo %! clf +%! contour(peaks()) +%! colorbar("west"); + +%!demo +%! clf %! subplot(2,2,1) %! contour(peaks()) %! colorbar("east"); @@ -532,3 +537,16 @@ %! colorbar (); %! colorbar (); +%!demo +%! clf +%! imagesc (1./hilb(99)); +%! h = colorbar; +%! set (h, 'yscale', 'log'); + +%!demo +%! clf +%! imagesc (log10 (1 ./ hilb (99))); +%! h = colorbar; +%! ytick = get(h, "ytick"); +%! set (h, "yticklabel", sprintf ('10^{%g}|', ytick)); +