comparison scripts/plot/util/private/__go_draw_axes__.m @ 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
comparison
equal deleted inserted replaced
18999:2ceb734a663f 19000:1ad621d894ba
1478 elseif (! isempty (axis_obj.ytick)) 1478 elseif (! isempty (axis_obj.ytick))
1479 if (strcmpi (axis_obj.yaxislocation, "right")) 1479 if (strcmpi (axis_obj.yaxislocation, "right"))
1480 fprintf (plot_stream, "unset ytics; set y2tics %s nomirror\n", 1480 fprintf (plot_stream, "unset ytics; set y2tics %s nomirror\n",
1481 axis_obj.tickdir); 1481 axis_obj.tickdir);
1482 if (strcmpi (axis_obj.xaxislocation, "top")) 1482 if (strcmpi (axis_obj.xaxislocation, "top"))
1483 fprintf (plot_stream, "unset xtics; set x2tics %s nomirror\n", 1483 maybe_do_x2tick_mirror (plot_stream, axis_obj)
1484 axis_obj.tickdir);
1485 fputs (plot_stream, "set border 12;\n"); 1484 fputs (plot_stream, "set border 12;\n");
1486 elseif (strcmpi (axis_obj.xaxislocation, "bottom")) 1485 elseif (strcmpi (axis_obj.xaxislocation, "bottom"))
1487 fprintf (plot_stream, "unset x2tics; set xtics %s nomirror\n", 1486 maybe_do_xtick_mirror (plot_stream, axis_obj)
1488 axis_obj.tickdir);
1489 fputs (plot_stream, "set border 9;\n"); 1487 fputs (plot_stream, "set border 9;\n");
1490 else # xaxislocation == zero 1488 else # xaxislocation == zero
1491 fprintf (plot_stream, "unset x2tics; set xtics %s nomirror\n", 1489 fprintf (plot_stream, "unset x2tics; set xtics %s nomirror\n",
1492 axis_obj.tickdir); 1490 axis_obj.tickdir);
1493 fputs (plot_stream, "set border 8;\n"); 1491 fputs (plot_stream, "set border 8;\n");
1496 endif 1494 endif
1497 elseif (strcmpi (axis_obj.yaxislocation, "left")) 1495 elseif (strcmpi (axis_obj.yaxislocation, "left"))
1498 fprintf (plot_stream, "unset y2tics; set ytics %s nomirror\n", 1496 fprintf (plot_stream, "unset y2tics; set ytics %s nomirror\n",
1499 axis_obj.tickdir); 1497 axis_obj.tickdir);
1500 if (strcmpi (axis_obj.xaxislocation, "top")) 1498 if (strcmpi (axis_obj.xaxislocation, "top"))
1501 fprintf (plot_stream, "unset xtics; set x2tics %s nomirror\n", 1499 maybe_do_x2tick_mirror (plot_stream, axis_obj)
1502 axis_obj.tickdir);
1503 fputs (plot_stream, "set border 6;\n"); 1500 fputs (plot_stream, "set border 6;\n");
1504 elseif (strcmpi (axis_obj.xaxislocation, "bottom")) 1501 elseif (strcmpi (axis_obj.xaxislocation, "bottom"))
1505 fprintf (plot_stream, "unset x2tics; set xtics %s nomirror\n", 1502 maybe_do_xtick_mirror (plot_stream, axis_obj)
1506 axis_obj.tickdir);
1507 fputs (plot_stream, "set border 3;\n"); 1503 fputs (plot_stream, "set border 3;\n");
1508 else # xaxislocation == zero 1504 else # xaxislocation == zero
1509 fprintf (plot_stream, "unset x2tics; set xtics %s nomirror\n", 1505 maybe_do_xtick_mirror (plot_stream, axis_obj)
1510 axis_obj.tickdir);
1511 fputs (plot_stream, "set border 2;\n"); 1506 fputs (plot_stream, "set border 2;\n");
1512 fprintf (plot_stream, "set xzeroaxis lt -1 lw %f;\n", 1507 fprintf (plot_stream, "set xzeroaxis lt -1 lw %f;\n",
1513 axis_obj.linewidth); 1508 axis_obj.linewidth);
1514 endif 1509 endif
1515 else # yaxislocation == zero 1510 else # yaxislocation == zero
1516 fprintf (plot_stream, "unset y2tics; set ytics %s nomirror\n", 1511 fprintf (plot_stream, "unset y2tics; set ytics %s nomirror\n",
1517 axis_obj.tickdir); 1512 axis_obj.tickdir);
1518 if (strcmpi (axis_obj.xaxislocation, "top")) 1513 if (strcmpi (axis_obj.xaxislocation, "top"))
1519 fprintf (plot_stream, "unset xtics; set x2tics %s nomirror\n", 1514 maybe_do_x2tick_mirror (plot_stream, axis_obj)
1520 axis_obj.tickdir);
1521 fputs (plot_stream, "set border 4;\n"); 1515 fputs (plot_stream, "set border 4;\n");
1522 elseif (strcmpi (axis_obj.xaxislocation, "bottom")) 1516 elseif (strcmpi (axis_obj.xaxislocation, "bottom"))
1523 fprintf (plot_stream, "unset x2tics; set xtics %s nomirror\n", 1517 maybe_do_xtick_mirror (plot_stream, axis_obj)
1524 axis_obj.tickdir);
1525 fputs (plot_stream, "set border 1;\n"); 1518 fputs (plot_stream, "set border 1;\n");
1526 else # xaxislocation == zero 1519 else # xaxislocation == zero
1520 maybe_do_xtick_mirror (plot_stream, axis_obj)
1527 fprintf (plot_stream, "unset y2tics; set ytics %s nomirror\n", 1521 fprintf (plot_stream, "unset y2tics; set ytics %s nomirror\n",
1528 axis_obj.tickdir);
1529 fprintf (plot_stream, "unset x2tics; set xtics %s nomirror\n",
1530 axis_obj.tickdir); 1522 axis_obj.tickdir);
1531 fputs (plot_stream, "unset border;\n"); 1523 fputs (plot_stream, "unset border;\n");
1532 fprintf (plot_stream, "set xzeroaxis lt -1 lw %f;\n", 1524 fprintf (plot_stream, "set xzeroaxis lt -1 lw %f;\n",
1533 axis_obj.linewidth); 1525 axis_obj.linewidth);
1534 endif 1526 endif
2137 2129
2138 function do_tics_1 (ticmode, tics, mtics, labelmode, labels, color, ax, 2130 function do_tics_1 (ticmode, tics, mtics, labelmode, labels, color, ax,
2139 plot_stream, mirror, mono, axispos, tickdir, ticklength, 2131 plot_stream, mirror, mono, axispos, tickdir, ticklength,
2140 fontname, fontspec, interpreter, scale, sgn, gnuplot_term) 2132 fontname, fontspec, interpreter, scale, sgn, gnuplot_term)
2141 persistent warned_latex = false; 2133 persistent warned_latex = false;
2134
2135 ## Avoid emitting anything if the tics are empty, because this undoes the
2136 ## effect of the previous unset xtics and thereby adds back in the tics.
2137 if (isempty (tics))
2138 return;
2139 endif
2140
2142 if (mirror) 2141 if (mirror)
2143 mirror = "mirror"; 2142 mirror = "mirror";
2144 else 2143 else
2145 mirror = "nomirror"; 2144 mirror = "nomirror";
2146 endif 2145 endif
2612 retval = "enhanced"; 2611 retval = "enhanced";
2613 endif 2612 endif
2614 endif 2613 endif
2615 endfunction 2614 endfunction
2616 2615
2616 function maybe_do_xtick_mirror (plot_stream, axis_obj)
2617 if (! isempty(axis_obj.xtick))
2618 fprintf (plot_stream, "unset x2tics; set xtics %s nomirror\n",
2619 axis_obj.tickdir);
2620 endif
2621 endfunction
2622
2623 function maybe_do_x2tick_mirror (plot_stream, axis_obj)
2624 if (! isempty(axis_obj.xtick))
2625 fprintf (plot_stream, "unset xtics; set x2tics %s nomirror\n",
2626 axis_obj.tickdir);
2627 endif
2628 endfunction
2629