Mercurial > hg > octave-lyh
comparison scripts/plot/__go_draw_axes__.m @ 7676:6c0f7bcf5b55
Fix spurious tics for plotyy with gnuplot backend
author | David Bateman <dbateman@free.fr> |
---|---|
date | Mon, 31 Mar 2008 22:12:01 -0400 |
parents | 49810341db91 |
children | da1f4bc7cbe8 |
comparison
equal
deleted
inserted
replaced
7675:8abada567409 | 7676:6c0f7bcf5b55 |
---|---|
1061 else | 1061 else |
1062 if (nd == 3) | 1062 if (nd == 3) |
1063 fputs (plot_stream, "set border 895;\n"); | 1063 fputs (plot_stream, "set border 895;\n"); |
1064 else | 1064 else |
1065 if (strcmpi (axis_obj.yaxislocation, "right")) | 1065 if (strcmpi (axis_obj.yaxislocation, "right")) |
1066 fputs (plot_stream, "unset ytics; set y2tics nomirror\n"); | 1066 fputs (plot_stream, "unset ytics; set y2tics %s nomirror\n", |
1067 axis_obj.tickdir); | |
1067 if (strcmpi (axis_obj.xaxislocation, "top")) | 1068 if (strcmpi (axis_obj.xaxislocation, "top")) |
1068 fputs (plot_stream, "unset xtics; set x2tics nomirror\n"); | 1069 fputs (plot_stream, "unset xtics; set x2tics %s nomirror\n", |
1070 axis_obj.tickdir); | |
1069 fputs (plot_stream, "set border 12;\n"); | 1071 fputs (plot_stream, "set border 12;\n"); |
1070 else | 1072 else |
1071 fputs (plot_stream, "unset x2tics; set xtics nomirror\n"); | 1073 fputs (plot_stream, "unset x2tics; set xtics %s nomirror\n", |
1074 axis_obj.tickdir); | |
1072 fputs (plot_stream, "set border 9;\n"); | 1075 fputs (plot_stream, "set border 9;\n"); |
1073 endif | 1076 endif |
1074 else | 1077 else |
1075 fputs (plot_stream, "unset y2tics; set ytics nomirror\n"); | 1078 fputs (plot_stream, "unset y2tics; set ytics %s nomirror\n", |
1079 axis_obj.tickdir); | |
1076 if (strcmpi (axis_obj.xaxislocation, "top")) | 1080 if (strcmpi (axis_obj.xaxislocation, "top")) |
1077 fputs (plot_stream, "unset xtics; set x2tics nomirror\n"); | 1081 fputs (plot_stream, "unset xtics; set x2tics %s nomirror\n", |
1082 axis_obj.tickdir); | |
1078 fputs (plot_stream, "set border 6;\n"); | 1083 fputs (plot_stream, "set border 6;\n"); |
1079 else | 1084 else |
1080 fputs (plot_stream, "unset x2tics; set xtics nomirror\n"); | 1085 fputs (plot_stream, "unset x2tics; set xtics %s nomirror\n", |
1086 axis_obj.tickdir); | |
1081 fputs (plot_stream, "set border 3;\n"); | 1087 fputs (plot_stream, "set border 3;\n"); |
1082 endif | 1088 endif |
1083 endif | 1089 endif |
1084 endif | 1090 endif |
1085 endif | 1091 endif |
1086 | 1092 |
1087 if (strcmpi (axis_obj.visible, "off")) | 1093 if (strcmpi (axis_obj.visible, "off")) |
1088 fputs (plot_stream, "unset border; unset tics\n"); | 1094 fputs (plot_stream, "unset border; unset tics\n"); |
1089 else | 1095 else |
1090 fprintf (plot_stream, "set border lw %f;\n", axis_obj.linewidth); | 1096 fprintf (plot_stream, "set border lw %f;\n", axis_obj.linewidth); |
1091 fprintf (plot_stream, "set tics %s\n", axis_obj.tickdir); | |
1092 endif | 1097 endif |
1093 | 1098 |
1094 if (strcmpi (axis_obj.key, "on")) | 1099 if (strcmpi (axis_obj.key, "on")) |
1095 if (strcmpi (axis_obj.keybox, "on")) | 1100 if (strcmpi (axis_obj.keybox, "on")) |
1096 box = "box"; | 1101 box = "box"; |
1469 endfunction | 1474 endfunction |
1470 | 1475 |
1471 function do_tics (obj, plot_stream, ymirror, mono) | 1476 function do_tics (obj, plot_stream, ymirror, mono) |
1472 if (strcmpi (obj.xaxislocation, "top")) | 1477 if (strcmpi (obj.xaxislocation, "top")) |
1473 do_tics_1 (obj.xtickmode, obj.xtick, obj.xticklabelmode, obj.xticklabel, | 1478 do_tics_1 (obj.xtickmode, obj.xtick, obj.xticklabelmode, obj.xticklabel, |
1474 obj.xcolor, "x2", plot_stream, true, mono, "border"); | 1479 obj.xcolor, "x2", plot_stream, true, mono, "border", |
1480 obj.tickdir); | |
1475 do_tics_1 ("manual", [], obj.xticklabelmode, obj.xticklabel, | 1481 do_tics_1 ("manual", [], obj.xticklabelmode, obj.xticklabel, |
1476 obj.xcolor, "x", plot_stream, true, mono, "border"); | 1482 obj.xcolor, "x", plot_stream, true, mono, "border", ""); |
1477 elseif (strcmpi (obj.xaxislocation, "zero")) | 1483 elseif (strcmpi (obj.xaxislocation, "zero")) |
1478 do_tics_1 (obj.xtickmode, obj.xtick, obj.xticklabelmode, obj.xticklabel, | 1484 do_tics_1 (obj.xtickmode, obj.xtick, obj.xticklabelmode, obj.xticklabel, |
1479 obj.xcolor, "x", plot_stream, true, mono, "axis"); | 1485 obj.xcolor, "x", plot_stream, true, mono, "axis", |
1486 obj.tickdir); | |
1480 do_tics_1 ("manual", [], obj.xticklabelmode, obj.xticklabel, | 1487 do_tics_1 ("manual", [], obj.xticklabelmode, obj.xticklabel, |
1481 obj.xcolor, "x2", plot_stream, true, mono, "axis"); | 1488 obj.xcolor, "x2", plot_stream, true, mono, "axis", ""); |
1482 else | 1489 else |
1483 do_tics_1 (obj.xtickmode, obj.xtick, obj.xticklabelmode, obj.xticklabel, | 1490 do_tics_1 (obj.xtickmode, obj.xtick, obj.xticklabelmode, obj.xticklabel, |
1484 obj.xcolor, "x", plot_stream, true, mono, "border"); | 1491 obj.xcolor, "x", plot_stream, true, mono, "border", |
1492 obj.tickdir); | |
1485 do_tics_1 ("manual", [], obj.xticklabelmode, obj.xticklabel, | 1493 do_tics_1 ("manual", [], obj.xticklabelmode, obj.xticklabel, |
1486 obj.xcolor, "x2", plot_stream, true, mono, "border"); | 1494 obj.xcolor, "x2", plot_stream, true, mono, "border", ""); |
1487 endif | 1495 endif |
1488 if (strcmpi (obj.yaxislocation, "right")) | 1496 if (strcmpi (obj.yaxislocation, "right")) |
1489 do_tics_1 (obj.ytickmode, obj.ytick, obj.yticklabelmode, obj.yticklabel, | 1497 do_tics_1 (obj.ytickmode, obj.ytick, obj.yticklabelmode, obj.yticklabel, |
1490 obj.ycolor, "y2", plot_stream, ymirror, mono, "border"); | 1498 obj.ycolor, "y2", plot_stream, ymirror, mono, "border", |
1499 obj.tickdir); | |
1491 do_tics_1 ("manual", [], obj.yticklabelmode, obj.yticklabel, | 1500 do_tics_1 ("manual", [], obj.yticklabelmode, obj.yticklabel, |
1492 obj.ycolor, "y", plot_stream, ymirror, mono, "border"); | 1501 obj.ycolor, "y", plot_stream, ymirror, mono, "border", ""); |
1493 elseif (strcmpi (obj.xaxislocation, "zero")) | 1502 elseif (strcmpi (obj.xaxislocation, "zero")) |
1494 do_tics_1 (obj.ytickmode, obj.ytick, obj.yticklabelmode, obj.yticklabel, | 1503 do_tics_1 (obj.ytickmode, obj.ytick, obj.yticklabelmode, obj.yticklabel, |
1495 obj.ycolor, "y", plot_stream, ymirror, mono, "axis"); | 1504 obj.ycolor, "y", plot_stream, ymirror, mono, "axis", |
1505 obj.tickdir); | |
1496 do_tics_1 ("manual", [], obj.yticklabelmode, obj.yticklabel, | 1506 do_tics_1 ("manual", [], obj.yticklabelmode, obj.yticklabel, |
1497 obj.ycolor, "y2", plot_stream, ymirror, mono, "axis"); | 1507 obj.ycolor, "y2", plot_stream, ymirror, mono, "axis", ""); |
1498 else | 1508 else |
1499 do_tics_1 (obj.ytickmode, obj.ytick, obj.yticklabelmode, obj.yticklabel, | 1509 do_tics_1 (obj.ytickmode, obj.ytick, obj.yticklabelmode, obj.yticklabel, |
1500 obj.ycolor, "y", plot_stream, ymirror, mono, "border"); | 1510 obj.ycolor, "y", plot_stream, ymirror, mono, "border", |
1511 obj.tickdir); | |
1501 do_tics_1 ("manual", [], obj.yticklabelmode, obj.yticklabel, | 1512 do_tics_1 ("manual", [], obj.yticklabelmode, obj.yticklabel, |
1502 obj.ycolor, "y2", plot_stream, ymirror, mono, "border"); | 1513 obj.ycolor, "y2", plot_stream, ymirror, mono, "border", ""); |
1503 endif | 1514 endif |
1504 do_tics_1 (obj.ztickmode, obj.ztick, obj.zticklabelmode, obj.zticklabel, | 1515 do_tics_1 (obj.ztickmode, obj.ztick, obj.zticklabelmode, obj.zticklabel, |
1505 obj.zcolor, "z", plot_stream, true, mono, "border"); | 1516 obj.zcolor, "z", plot_stream, true, mono, "border", |
1517 obj.tickdir); | |
1506 endfunction | 1518 endfunction |
1507 | 1519 |
1508 function do_tics_1 (ticmode, tics, labelmode, labels, color, ax, | 1520 function do_tics_1 (ticmode, tics, labelmode, labels, color, ax, |
1509 plot_stream, mirror, mono, axispos) | 1521 plot_stream, mirror, mono, axispos, tickdir) |
1510 colorspec = get_text_colorspec (color, mono); | 1522 colorspec = get_text_colorspec (color, mono); |
1511 if (strcmpi (ticmode, "manual")) | 1523 if (strcmpi (ticmode, "manual")) |
1512 if (isempty (tics)) | 1524 if (isempty (tics)) |
1513 fprintf (plot_stream, "unset %stics;\n", ax); | 1525 fprintf (plot_stream, "unset %stics;\n", ax); |
1514 elseif (strcmpi (labelmode, "manual") && ! isempty (labels)) | 1526 elseif (strcmpi (labelmode, "manual") && ! isempty (labels)) |
1519 k = 1; | 1531 k = 1; |
1520 ntics = numel (tics); | 1532 ntics = numel (tics); |
1521 nlabels = numel (labels); | 1533 nlabels = numel (labels); |
1522 fprintf (plot_stream, "set format %s \"%%s\";\n", ax); | 1534 fprintf (plot_stream, "set format %s \"%%s\";\n", ax); |
1523 if (mirror) | 1535 if (mirror) |
1524 fprintf (plot_stream, "set %stics %s (", ax, axispos); | 1536 fprintf (plot_stream, "set %stics %s %s (", ax, tickdir, axispos); |
1525 else | 1537 else |
1526 fprintf (plot_stream, "set %stics %s nomirror (", ax, axispos); | 1538 fprintf (plot_stream, "set %stics %s %s nomirror (", ax, |
1539 tickdir, axispos); | |
1527 endif | 1540 endif |
1528 labels = regexprep(labels, "%", "%%"); | 1541 labels = regexprep(labels, "%", "%%"); |
1529 for i = 1:ntics | 1542 for i = 1:ntics |
1530 fprintf (plot_stream, " \"%s\" %g", labels{k++}, tics(i)); | 1543 fprintf (plot_stream, " \"%s\" %g", labels{k++}, tics(i)); |
1531 if (i < ntics) | 1544 if (i < ntics) |
1540 error ("unsupported type of ticklabel"); | 1553 error ("unsupported type of ticklabel"); |
1541 endif | 1554 endif |
1542 else | 1555 else |
1543 fprintf (plot_stream, "set format %s \"%%g\";\n", ax); | 1556 fprintf (plot_stream, "set format %s \"%%g\";\n", ax); |
1544 if (mirror) | 1557 if (mirror) |
1545 fprintf (plot_stream, "set %stics %s (", ax, axispos ); | 1558 fprintf (plot_stream, "set %stics %s %s (", ax, tickdir, axispos ); |
1546 else | 1559 else |
1547 fprintf (plot_stream, "set %stics %s nomirror (", ax, axispos); | 1560 fprintf (plot_stream, "set %stics %s %s nomirror (", ax, tickdir, |
1561 axispos); | |
1548 endif | 1562 endif |
1549 fprintf (plot_stream, " %g,", tics(1:end-1)); | 1563 fprintf (plot_stream, " %g,", tics(1:end-1)); |
1550 fprintf (plot_stream, " %g);\n", tics(end)); | 1564 fprintf (plot_stream, " %g);\n", tics(end)); |
1551 endif | 1565 endif |
1552 else | 1566 else |
1553 fprintf (plot_stream, "set format %s \"%%g\";\n", ax); | 1567 fprintf (plot_stream, "set format %s \"%%g\";\n", ax); |
1554 if (mirror) | 1568 if (mirror) |
1555 fprintf (plot_stream, "set %stics %s %s;\n", ax, axispos, colorspec); | 1569 fprintf (plot_stream, "set %stics %s %s %s;\n", ax, axispos, tickdir, |
1556 else | 1570 colorspec); |
1557 fprintf (plot_stream, "set %stics %s nomirror %s;\n", ax, | 1571 else |
1558 axispos, colorspec); | 1572 fprintf (plot_stream, "set %stics %s %s nomirror %s;\n", ax, |
1573 tickdir, axispos, colorspec); | |
1559 endif | 1574 endif |
1560 endif | 1575 endif |
1561 endfunction | 1576 endfunction |
1562 | 1577 |
1563 function colorspec = get_text_colorspec (color, mono) | 1578 function colorspec = get_text_colorspec (color, mono) |