# HG changeset patch # User Ben Abbott # Date 1243506061 14400 # Node ID 02b16eeb3167876e7beef434f64867cf0d395c06 # Parent 40fb718a2e6753a30f93f2af9a5c8ff55c5b4ecd Fix yticklabels for log scale colorbar. diff --git a/scripts/ChangeLog b/scripts/ChangeLog --- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,11 @@ +2009-05-28 Ben Abbott + + * 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 * plot/__go_draw_axes__.m: Add support for ticklabel separator '|'. diff --git a/scripts/plot/__go_draw_axes__.m b/scripts/plot/__go_draw_axes__.m --- 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(n10) - 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 diff --git a/scripts/plot/__go_draw_figure__.m b/scripts/plot/__go_draw_figure__.m --- 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"); diff --git a/scripts/plot/colorbar.m b/scripts/plot/colorbar.m --- 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)); +