# HG changeset patch # User Serviscope Minor # Date 1407512454 -3600 # Node ID 1ad621d894bac1cd6207d47bc504b57403171e11 # Parent 2ceb734a663f9a1bdcb69219378cfac714532aea 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. diff -r 2ceb734a663f -r 1ad621d894ba scripts/plot/util/private/__go_draw_axes__.m --- 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 +