Mercurial > hg > octave-lyh
comparison scripts/plot/__go_draw_axes__.m @ 6914:40be41c7d098
[project @ 2007-09-18 19:51:06 by jwe]
author | jwe |
---|---|
date | Tue, 18 Sep 2007 19:51:06 +0000 |
parents | 66c7da4ee7a1 |
children | 17d9ce1f00f5 |
comparison
equal
deleted
inserted
replaced
6913:f779c83d6ccf | 6914:40be41c7d098 |
---|---|
34 | 34 |
35 ## Set axis properties here? | 35 ## Set axis properties here? |
36 | 36 |
37 if (! isempty (axis_obj.outerposition)) | 37 if (! isempty (axis_obj.outerposition)) |
38 pos = axis_obj.outerposition; | 38 pos = axis_obj.outerposition; |
39 fprintf (plot_stream, "set origin %g, %g;\n", pos(1), pos(2)); | 39 fprintf (plot_stream, "set origin %.15g, %.15g;\n", pos(1), pos(2)); |
40 fprintf (plot_stream, "set size %g, %g;\n", pos(3), pos(4)); | 40 fprintf (plot_stream, "set size %.15g, %.15g;\n", pos(3), pos(4)); |
41 endif | 41 endif |
42 | 42 |
43 if (! isempty (axis_obj.position)) | 43 if (! isempty (axis_obj.position)) |
44 pos = axis_obj.position; | 44 pos = axis_obj.position; |
45 fprintf (plot_stream, "set origin %g, %g;\n", pos(1), pos(2)); | 45 fprintf (plot_stream, "set origin %.15g, %.15g;\n", pos(1), pos(2)); |
46 fprintf (plot_stream, "set size %g, %g;\n", pos(3), pos(4)); | 46 fprintf (plot_stream, "set size %.15g, %.15g;\n", pos(3), pos(4)); |
47 endif | 47 endif |
48 | 48 |
49 if (strcmpi (axis_obj.dataaspectratiomode, "manual")) | 49 if (strcmpi (axis_obj.dataaspectratiomode, "manual")) |
50 r = axis_obj.dataaspectratio; | 50 r = axis_obj.dataaspectratio; |
51 fprintf (plot_stream, "set size ratio %g;\n", -r(2)/r(1)); | 51 fprintf (plot_stream, "set size ratio %.15g;\n", -r(2)/r(1)); |
52 else | 52 else |
53 fputs (plot_stream, "set size noratio;\n"); | 53 fputs (plot_stream, "set size noratio;\n"); |
54 endif | 54 endif |
55 | 55 |
56 fputs (plot_stream, "unset label;\n"); | 56 fputs (plot_stream, "unset label;\n"); |
286 palette_size); | 286 palette_size); |
287 fwrite (plot_stream, [1:palette_size; img_colormap'], "float32"); | 287 fwrite (plot_stream, [1:palette_size; img_colormap'], "float32"); |
288 endif | 288 endif |
289 | 289 |
290 titlespec{data_idx} = "title \"\""; | 290 titlespec{data_idx} = "title \"\""; |
291 usingclause{data_idx} = sprintf ("binary array=%dx%d scan=yx origin=(%g,%g) dx=%g dy=%g using %s", | 291 usingclause{data_idx} = sprintf ("binary array=%dx%d scan=yx origin=(%.15g,%.15g) dx=%.15g dy=%.15g using %s", |
292 x_dim, y_dim, x_origin, y_origin, dx, dy, format); | 292 x_dim, y_dim, x_origin, y_origin, dx, dy, format); |
293 withclause{data_idx} = sprintf ("with %s", imagetype); | 293 withclause{data_idx} = sprintf ("with %s", imagetype); |
294 | 294 |
295 else | 295 else |
296 ximg_data{++ximg_data_idx} = img_data; | 296 ximg_data{++ximg_data_idx} = img_data; |
670 endif | 670 endif |
671 endif | 671 endif |
672 | 672 |
673 if (nd == 3) | 673 if (nd == 3) |
674 fprintf (plot_stream, | 674 fprintf (plot_stream, |
675 "set label \"%s\" at %s %g,%g,%g %s rotate by %f %s;\n", | 675 "set label \"%s\" at %s %.15g,%.15g,%.15g %s rotate by %f %s;\n", |
676 undo_string_escapes (label), units, | 676 undo_string_escapes (label), units, |
677 lpos(1), lpos(2), lpos(3), halign, angle, colorspec); | 677 lpos(1), lpos(2), lpos(3), halign, angle, colorspec); |
678 else | 678 else |
679 fprintf (plot_stream, | 679 fprintf (plot_stream, |
680 "set label \"%s\" at %s %g,%g %s rotate by %f %s;\n", | 680 "set label \"%s\" at %s %.15g,%.15g %s rotate by %f %s;\n", |
681 undo_string_escapes (label), units, | 681 undo_string_escapes (label), units, |
682 lpos(1), lpos(2), halign, angle, colorspec); | 682 lpos(1), lpos(2), halign, angle, colorspec); |
683 endif | 683 endif |
684 | 684 |
685 otherwise | 685 otherwise |
700 if (strcmpi (axis_obj.xdir, "reverse")) | 700 if (strcmpi (axis_obj.xdir, "reverse")) |
701 xdir = "reverse"; | 701 xdir = "reverse"; |
702 else | 702 else |
703 xdir = "noreverse"; | 703 xdir = "noreverse"; |
704 endif | 704 endif |
705 fprintf (plot_stream, "set %srange [%g:%g] %s;\n", xaxisloc, xlim, xdir); | 705 fprintf (plot_stream, "set %srange [%.15g:%.15g] %s;\n", xaxisloc, xlim, xdir); |
706 | 706 |
707 if (yautoscale && have_data) | 707 if (yautoscale && have_data) |
708 ylim = get_axis_limits (ymin, ymax, yminp, ylogscale); | 708 ylim = get_axis_limits (ymin, ymax, yminp, ylogscale); |
709 set (h, "ylim", ylim, "ylimmode", "auto"); | 709 set (h, "ylim", ylim, "ylimmode", "auto"); |
710 else | 710 else |
713 if (strcmpi (axis_obj.ydir, "reverse")) | 713 if (strcmpi (axis_obj.ydir, "reverse")) |
714 ydir = "reverse"; | 714 ydir = "reverse"; |
715 else | 715 else |
716 ydir = "noreverse"; | 716 ydir = "noreverse"; |
717 endif | 717 endif |
718 fprintf (plot_stream, "set %srange [%g:%g] %s;\n", yaxisloc, ylim, ydir); | 718 fprintf (plot_stream, "set %srange [%.15g:%.15g] %s;\n", yaxisloc, ylim, ydir); |
719 | 719 |
720 if (nd == 3) | 720 if (nd == 3) |
721 if (zautoscale && have_data) | 721 if (zautoscale && have_data) |
722 zlim = get_axis_limits (zmin, zmax, zminp, zlogscale); | 722 zlim = get_axis_limits (zmin, zmax, zminp, zlogscale); |
723 set (h, "zlim", zlim, "zlimmode", "auto"); | 723 set (h, "zlim", zlim, "zlimmode", "auto"); |
727 if (strcmpi (axis_obj.zdir, "reverse")) | 727 if (strcmpi (axis_obj.zdir, "reverse")) |
728 zdir = "reverse"; | 728 zdir = "reverse"; |
729 else | 729 else |
730 zdir = "noreverse"; | 730 zdir = "noreverse"; |
731 endif | 731 endif |
732 fprintf (plot_stream, "set zrange [%g:%g] %s;\n", zlim, zdir); | 732 fprintf (plot_stream, "set zrange [%.15g:%.15g] %s;\n", zlim, zdir); |
733 endif | 733 endif |
734 | 734 |
735 if (strcmpi (axis_obj.box, "on")) | 735 if (strcmpi (axis_obj.box, "on")) |
736 if (nd == 3) | 736 if (nd == 3) |
737 fputs (plot_stream, "set border 4095;\n"); | 737 fputs (plot_stream, "set border 4095;\n"); |
795 rot_z = axis_obj.view(1); | 795 rot_z = axis_obj.view(1); |
796 while (rot_z < 0) | 796 while (rot_z < 0) |
797 rot_z += 360; | 797 rot_z += 360; |
798 endwhile | 798 endwhile |
799 fputs (plot_stream, "set ticslevel 0;\n"); | 799 fputs (plot_stream, "set ticslevel 0;\n"); |
800 fprintf (plot_stream, "set view %g, %g;\n", rot_x, rot_z); | 800 fprintf (plot_stream, "set view %.15g, %.15g;\n", rot_x, rot_z); |
801 endif | 801 endif |
802 fprintf (plot_stream, "%s \"-\" %s %s %s \\\n", plot_cmd, | 802 fprintf (plot_stream, "%s \"-\" %s %s %s \\\n", plot_cmd, |
803 usingclause{1}, titlespec{1}, withclause{1}); | 803 usingclause{1}, titlespec{1}, withclause{1}); |
804 for i = 2:data_idx | 804 for i = 2:data_idx |
805 fprintf (plot_stream, ", \"-\" %s %s %s \\\n", | 805 fprintf (plot_stream, ", \"-\" %s %s %s \\\n", |
1054 data(idx) = NaN; | 1054 data(idx) = NaN; |
1055 endif | 1055 endif |
1056 | 1056 |
1057 if (nd == 2) | 1057 if (nd == 2) |
1058 nan_elts = find (sum (isnan (data))); | 1058 nan_elts = find (sum (isnan (data))); |
1059 fmt = strcat (repmat ("%e ", 1, rows (data)), "\n"); | 1059 fmt = strcat (repmat ("%.15g ", 1, rows (data)), "\n"); |
1060 if (isempty (nan_elts)) | 1060 if (isempty (nan_elts)) |
1061 fprintf (plot_stream, fmt, data); | 1061 fprintf (plot_stream, fmt, data); |
1062 else | 1062 else |
1063 n = columns (data); | 1063 n = columns (data); |
1064 have_nans = true; | 1064 have_nans = true; |
1074 endfor | 1074 endfor |
1075 endif | 1075 endif |
1076 else | 1076 else |
1077 ## FIXME -- handle NaNs here too? | 1077 ## FIXME -- handle NaNs here too? |
1078 if (parametric) | 1078 if (parametric) |
1079 fprintf (plot_stream, "%e %e %e\n", data); | 1079 fprintf (plot_stream, "%.15g %.15g %.15g\n", data); |
1080 else | 1080 else |
1081 nc = columns (data); | 1081 nc = columns (data); |
1082 for j = 1:3:nc | 1082 for j = 1:3:nc |
1083 fprintf (plot_stream, "%e %e %e\n", data(:,j:j+2)'); | 1083 fprintf (plot_stream, "%.15g %.15g %.15g\n", data(:,j:j+2)'); |
1084 fputs (plot_stream, "\n"); | 1084 fputs (plot_stream, "\n"); |
1085 endfor | 1085 endfor |
1086 endif | 1086 endif |
1087 endif | 1087 endif |
1088 fputs (plot_stream, "e\n"); | 1088 fputs (plot_stream, "e\n"); |
1129 ntics = numel (tics); | 1129 ntics = numel (tics); |
1130 nlabels = numel (labels); | 1130 nlabels = numel (labels); |
1131 fprintf (plot_stream, "set format %s \"%%s\";\n", ax); | 1131 fprintf (plot_stream, "set format %s \"%%s\";\n", ax); |
1132 fprintf (plot_stream, "set %stics (", ax); | 1132 fprintf (plot_stream, "set %stics (", ax); |
1133 for i = 1:ntics | 1133 for i = 1:ntics |
1134 fprintf (plot_stream, " \"%s\" %g", labels(k++), tics(i)) | 1134 fprintf (plot_stream, " \"%s\" %.15g", labels(k++), tics(i)) |
1135 if (i < ntics) | 1135 if (i < ntics) |
1136 fputs (plot_stream, ", "); | 1136 fputs (plot_stream, ", "); |
1137 endif | 1137 endif |
1138 if (k > nlabels) | 1138 if (k > nlabels) |
1139 k = 1; | 1139 k = 1; |
1142 fputs (plot_stream, ");\n"); | 1142 fputs (plot_stream, ");\n"); |
1143 else | 1143 else |
1144 error ("unsupported type of ticklabel"); | 1144 error ("unsupported type of ticklabel"); |
1145 endif | 1145 endif |
1146 else | 1146 else |
1147 fprintf (plot_stream, "set format %s \"%%.15g\";\n", ax); | |
1147 fprintf (plot_stream, "set %stics (", ax); | 1148 fprintf (plot_stream, "set %stics (", ax); |
1148 fprintf (plot_stream, " %g,", tics(1:end-1)); | 1149 fprintf (plot_stream, " %.15g,", tics(1:end-1)); |
1149 fprintf (plot_stream, " %g);\n", tics(end)); | 1150 fprintf (plot_stream, " %.15g);\n", tics(end)); |
1150 endif | 1151 endif |
1151 else | 1152 else |
1153 fprintf (plot_stream, "set format %s \"%%.15g\";\n", ax); | |
1152 fprintf (plot_stream, "set %stics;\n", ax); | 1154 fprintf (plot_stream, "set %stics;\n", ax); |
1153 endif | 1155 endif |
1154 endfunction | 1156 endfunction |