# HG changeset patch # User jwe # Date 1182232808 0 # Node ID ca6668e475182a2bec8b77a0a5eb62c24312e4b6 # Parent b6c6587c1fb0e918d15b3b0c3b184a5653d7deec [project @ 2007-06-19 06:00:08 by jwe] diff -r b6c6587c1fb0 -r ca6668e47518 scripts/ChangeLog --- a/scripts/ChangeLog Mon Jun 18 19:56:28 2007 +0000 +++ b/scripts/ChangeLog Tue Jun 19 06:00:08 2007 +0000 @@ -1,3 +1,8 @@ +2007-06-19 John W. Eaton + + * plot/__go_draw_axes__.m (do_tics, do_tics_1): New functions. + (__go_draw_axes__): Call do_tics to handle tic marks. + 2007-06-18 Søren Hauberg * general/interp1.m, general/interp2.m, general/interp3.m, diff -r b6c6587c1fb0 -r ca6668e47518 scripts/plot/__go_draw_axes__.m --- a/scripts/plot/__go_draw_axes__.m Mon Jun 18 19:56:28 2007 +0000 +++ b/scripts/plot/__go_draw_axes__.m Tue Jun 19 06:00:08 2007 +0000 @@ -154,65 +154,7 @@ fputs (plot_stream, "set grid nomztics;\n"); endif - if (strcmp (axis_obj.xtickmode, "manual")) - xtic = axis_obj.xtick; - if (isempty (xtic)) - fputs (plot_stream, "unset xtics;\n"); - else - ## FIXME - endif - else - fputs (plot_stream, "set xtics;\n"); - endif - - if (strcmp (axis_obj.ytickmode, "manual")) - ytic = axis_obj.ytick; - if (isempty (ytic)) - fputs (plot_stream, "unset ytics;\n"); - else - ## FIXME - endif - else - fputs (plot_stream, "set ytics;\n"); - endif - - if (strcmp (axis_obj.ztickmode, "manual")) - ztic = axis_obj.ztick; - if (isempty (ztic)) - fputs (plot_stream, "unset ztics;\n"); - else - ## FIXME - endif - else - fputs (plot_stream, "set ztics;\n"); - endif - - if (strcmp (axis_obj.xticklabelmode, "manual")) - ## FIXME -- we should be able to specify the actual tick labels, - ## not just the format. - xticlabel = axis_obj.xticklabel; - fprintf (plot_stream, "set format x \"%s\";\n", xticlabel); - else - fputs (plot_stream, "set xtics;\n"); - endif - - if (strcmp (axis_obj.yticklabelmode, "manual")) - ## FIXME -- we should be able to specify the actual tick labels, - ## not just the format. - yticlabel = axis_obj.yticklabel; - fprintf (plot_stream, "set format y \"%s\";\n", yticlabel); - else - fputs (plot_stream, "set ytics;\n"); - endif - - if (strcmp (axis_obj.zticklabelmode, "manual")) - ## FIXME -- we should be able to specify the actual tick labels, - ## not just the format. - zticlabel = axis_obj.zticklabel; - fprintf (plot_stream, "set format z \"%s\";\n", zticlabel); - else - fputs (plot_stream, "set ztics;\n"); - endif + do_tics (axis_obj, plot_stream); xlogscale = strcmp (axis_obj.xscale, "log"); if (xlogscale) @@ -953,3 +895,46 @@ fputs (plot_stream, "e\n"); endfunction + +function do_tics (obj, plot_stream) + do_tics_1 (obj.xtickmode, obj.xtick, obj.xticklabelmode, obj.xticklabel, + "x", plot_stream); + do_tics_1 (obj.ytickmode, obj.ytick, obj.yticklabelmode, obj.yticklabel, + "y", plot_stream); + do_tics_1 (obj.ztickmode, obj.ztick, obj.zticklabelmode, obj.zticklabel, + "z", plot_stream); +endfunction + +function do_tics_1 (ticmode, tics, labelmode, labels, ax, plot_stream) + if (strcmp (ticmode, "manual")) + if (isempty (tics)) + fprintf (plot_stream, "unset %stics;\n", ax); + elseif (strcmp (labelmode, "manual") && ! isempty (labels)) + k = 1; + ntics = numel (tics); + nlabels = numel (labels); + if (iscellstr (labels)) + fprintf (plot_stream, "set format %s \"%%s\";\n", ax); + fprintf (plot_stream, "set %stics (", ax); + for i = 1:ntics + fprintf (plot_stream, " \"%s\" %g", labels(k++), tics(i)) + if (i < ntics) + fputs (plot_stream, ", "); + endif + if (k > nlabels) + k = 1; + endif + endfor + fputs (plot_stream, ");\n"); + else + error ("unsupported type of ticklabel"); + endif + else + fprintf (plot_stream, "set %stics (", ax); + fprintf (plot_stream, " %g,", xtic(1:end-1)); + fprintf (plot_stream, " %g);\n", xtic(end)); + endif + else + fprintf (plot_stream, "set %stics;\n", ax); + endif +endfunction