Mercurial > octave-dspies
changeset 19000:1ad621d894ba
Fix set(gca, 'xtick', []) with gnuplot backend (bug #42936).
* __go_draw_axes__.m: initially "unset xtick;" is issued.
To avoid the ticks reappearing, all set xtick commands have to be omitted
if xtick == [], otherwise gnuplot fills in the ticks even if (say) only
the mirroring state is set.
author | Serviscope Minor <serviscope_minor@verybigfrog.com> |
---|---|
date | Fri, 08 Aug 2014 16:40:54 +0100 |
parents | 2ceb734a663f |
children | 391e080ae810 |
files | scripts/plot/util/private/__go_draw_axes__.m |
diffstat | 1 files changed, 29 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/plot/util/private/__go_draw_axes__.m Fri Aug 08 15:35:49 2014 +0100 +++ b/scripts/plot/util/private/__go_draw_axes__.m Fri Aug 08 16:40:54 2014 +0100 @@ -1480,12 +1480,10 @@ fprintf (plot_stream, "unset ytics; set y2tics %s nomirror\n", axis_obj.tickdir); if (strcmpi (axis_obj.xaxislocation, "top")) - fprintf (plot_stream, "unset xtics; set x2tics %s nomirror\n", - axis_obj.tickdir); + maybe_do_x2tick_mirror (plot_stream, axis_obj) fputs (plot_stream, "set border 12;\n"); elseif (strcmpi (axis_obj.xaxislocation, "bottom")) - fprintf (plot_stream, "unset x2tics; set xtics %s nomirror\n", - axis_obj.tickdir); + maybe_do_xtick_mirror (plot_stream, axis_obj) fputs (plot_stream, "set border 9;\n"); else # xaxislocation == zero fprintf (plot_stream, "unset x2tics; set xtics %s nomirror\n", @@ -1498,16 +1496,13 @@ fprintf (plot_stream, "unset y2tics; set ytics %s nomirror\n", axis_obj.tickdir); if (strcmpi (axis_obj.xaxislocation, "top")) - fprintf (plot_stream, "unset xtics; set x2tics %s nomirror\n", - axis_obj.tickdir); + maybe_do_x2tick_mirror (plot_stream, axis_obj) fputs (plot_stream, "set border 6;\n"); elseif (strcmpi (axis_obj.xaxislocation, "bottom")) - fprintf (plot_stream, "unset x2tics; set xtics %s nomirror\n", - axis_obj.tickdir); + maybe_do_xtick_mirror (plot_stream, axis_obj) fputs (plot_stream, "set border 3;\n"); else # xaxislocation == zero - fprintf (plot_stream, "unset x2tics; set xtics %s nomirror\n", - axis_obj.tickdir); + maybe_do_xtick_mirror (plot_stream, axis_obj) fputs (plot_stream, "set border 2;\n"); fprintf (plot_stream, "set xzeroaxis lt -1 lw %f;\n", axis_obj.linewidth); @@ -1516,18 +1511,15 @@ fprintf (plot_stream, "unset y2tics; set ytics %s nomirror\n", axis_obj.tickdir); if (strcmpi (axis_obj.xaxislocation, "top")) - fprintf (plot_stream, "unset xtics; set x2tics %s nomirror\n", - axis_obj.tickdir); + maybe_do_x2tick_mirror (plot_stream, axis_obj) fputs (plot_stream, "set border 4;\n"); elseif (strcmpi (axis_obj.xaxislocation, "bottom")) - fprintf (plot_stream, "unset x2tics; set xtics %s nomirror\n", - axis_obj.tickdir); + maybe_do_xtick_mirror (plot_stream, axis_obj) fputs (plot_stream, "set border 1;\n"); else # xaxislocation == zero + maybe_do_xtick_mirror (plot_stream, axis_obj) fprintf (plot_stream, "unset y2tics; set ytics %s nomirror\n", axis_obj.tickdir); - fprintf (plot_stream, "unset x2tics; set xtics %s nomirror\n", - axis_obj.tickdir); fputs (plot_stream, "unset border;\n"); fprintf (plot_stream, "set xzeroaxis lt -1 lw %f;\n", axis_obj.linewidth); @@ -2139,6 +2131,13 @@ plot_stream, mirror, mono, axispos, tickdir, ticklength, fontname, fontspec, interpreter, scale, sgn, gnuplot_term) persistent warned_latex = false; + + ## Avoid emitting anything if the tics are empty, because this undoes the + ## effect of the previous unset xtics and thereby adds back in the tics. + if (isempty (tics)) + return; + endif + if (mirror) mirror = "mirror"; else @@ -2614,3 +2613,17 @@ endif endfunction +function maybe_do_xtick_mirror (plot_stream, axis_obj) + if (! isempty(axis_obj.xtick)) + fprintf (plot_stream, "unset x2tics; set xtics %s nomirror\n", + axis_obj.tickdir); + endif +endfunction + +function maybe_do_x2tick_mirror (plot_stream, axis_obj) + if (! isempty(axis_obj.xtick)) + fprintf (plot_stream, "unset xtics; set x2tics %s nomirror\n", + axis_obj.tickdir); + endif +endfunction +