comparison scripts/plot/util/private/__go_draw_axes__.m @ 19833:9fc020886ae9

maint: Clean up m-files to follow Octave coding conventions. Try to trim long lines to < 80 chars. Use '##' for single line comments. Use '(...)' around tests for if/elseif/switch/while. Abut cell indexing operator '{' next to variable. Abut array indexing operator '(' next to variable. Use space between negation operator '!' and following expression. Use two newlines between endfunction and start of %!test or %!demo code. Remove unnecessary parens grouping between short-circuit operators. Remove stray extra spaces (typos) between variables and assignment operators. Remove stray extra spaces from ends of lines.
author Rik <rik@octave.org>
date Mon, 23 Feb 2015 14:54:39 -0800
parents 5f2c0ca0ef51
children e10ad5214a59
comparison
equal deleted inserted replaced
19832:a1acca0c2216 19833:9fc020886ae9
707 && isfield (obj, "cdata")) 707 && isfield (obj, "cdata"))
708 if (ndims (obj.cdata) == 2 708 if (ndims (obj.cdata) == 2
709 && (columns (obj.cdata) == nc 709 && (columns (obj.cdata) == nc
710 && (rows (obj.cdata) == 1 710 && (rows (obj.cdata) == 1
711 || rows (obj.cdata) == 3))) 711 || rows (obj.cdata) == 3)))
712 ccol = cdat (:, i); 712 ccol = cdat(:, i);
713 elseif (ndims (obj.cdata) == 2 713 elseif (ndims (obj.cdata) == 2
714 && (rows (obj.cdata) == nc 714 && (rows (obj.cdata) == nc
715 && (columns (obj.cdata) == 1 715 && (columns (obj.cdata) == 1
716 || columns (obj.cdata) == 3))) 716 || columns (obj.cdata) == 3)))
717 ccol = cdat (i, :); 717 ccol = cdat(i, :);
718 elseif (ndims (obj.cdata) == 3) 718 elseif (ndims (obj.cdata) == 3)
719 ccol = permute (cdat (:, i, :), [1, 3, 2]); 719 ccol = permute (cdat (:, i, :), [1, 3, 2]);
720 else 720 else
721 ccol = cdat; 721 ccol = cdat;
722 endif 722 endif
840 && isfield (obj, "cdata")) 840 && isfield (obj, "cdata"))
841 if (ndims (obj.cdata) == 2 841 if (ndims (obj.cdata) == 2
842 && (columns (obj.cdata) == nc 842 && (columns (obj.cdata) == nc
843 && (rows (obj.cdata) == 1 843 && (rows (obj.cdata) == 1
844 || rows (obj.cdata) == 3))) 844 || rows (obj.cdata) == 3)))
845 ccol = cdat (:, i); 845 ccol = cdat(:, i);
846 elseif (ndims (obj.cdata) == 2 846 elseif (ndims (obj.cdata) == 2
847 && (rows (obj.cdata) == nc 847 && (rows (obj.cdata) == nc
848 && (columns (obj.cdata) == 1 848 && (columns (obj.cdata) == 1
849 || columns (obj.cdata) == 3))) 849 || columns (obj.cdata) == 3)))
850 ccol = cdat (i, :); 850 ccol = cdat(i, :);
851 elseif (ndims (obj.cdata) == 3) 851 elseif (ndims (obj.cdata) == 3)
852 ccol = permute (cdat (:, i, :), [1, 3, 2]); 852 ccol = permute (cdat (:, i, :), [1, 3, 2]);
853 else 853 else
854 ccol = cdat; 854 ccol = cdat;
855 endif 855 endif
904 endif 904 endif
905 905
906 if (isfield (obj, "linewidth")) 906 if (isfield (obj, "linewidth"))
907 lw = sprintf ("linewidth %f", obj.linewidth); 907 lw = sprintf ("linewidth %f", obj.linewidth);
908 else 908 else
909 lw = ""; 909 lw = "";
910 endif 910 endif
911 911
912 [pt, pt2, obj] = gnuplot_pointtype (obj); 912 [pt, pt2, obj] = gnuplot_pointtype (obj);
913 if (! isempty (pt)) 913 if (! isempty (pt))
914 pt = sprintf ("pointtype %s", pt); 914 pt = sprintf ("pointtype %s", pt);
936 endif 936 endif
937 tmpwith = {}; 937 tmpwith = {};
938 938
939 facesame = true; 939 facesame = true;
940 if (! isequal (pt, pt2) && isfield (obj, "markerfacecolor") 940 if (! isequal (pt, pt2) && isfield (obj, "markerfacecolor")
941 && !strcmp (obj.markerfacecolor, "none")) 941 && ! strcmp (obj.markerfacecolor, "none"))
942 if (strcmp (obj.markerfacecolor, "auto") 942 if (strcmp (obj.markerfacecolor, "auto")
943 || ! isnumeric (obj.markerfacecolor) 943 || ! isnumeric (obj.markerfacecolor)
944 || (isnumeric (obj.markerfacecolor) 944 || (isnumeric (obj.markerfacecolor)
945 && isequal (color, obj.markerfacecolor))) 945 && isequal (color, obj.markerfacecolor)))
946 style = strcat (style, "points"); 946 style = strcat (style, "points");
986 colorspec); 986 colorspec);
987 endif 987 endif
988 endif 988 endif
989 989
990 if (isfield (obj, "markeredgecolor") 990 if (isfield (obj, "markeredgecolor")
991 && !strcmp (obj.markeredgecolor, "none")) 991 && ! strcmp (obj.markeredgecolor, "none"))
992 if (facesame && !isempty (pt) 992 if (facesame && ! isempty (pt)
993 && (strcmp (obj.markeredgecolor, "auto") 993 && (strcmp (obj.markeredgecolor, "auto")
994 || ! isnumeric (obj.markeredgecolor) 994 || ! isnumeric (obj.markeredgecolor)
995 || (isnumeric (obj.markeredgecolor) 995 || (isnumeric (obj.markeredgecolor)
996 && isequal (color, obj.markeredgecolor)))) 996 && isequal (color, obj.markeredgecolor))))
997 if (sidx == 1 && ((length (style) == 5 997 if (sidx == 1 && ((length (style) == 5
1011 tmpwith{sidx} = sprintf ("with %s %s %s %s %s %s", 1011 tmpwith{sidx} = sprintf ("with %s %s %s %s %s %s",
1012 style, lw, pt, lt, ps, 1012 style, lw, pt, lt, ps,
1013 colorspec); 1013 colorspec);
1014 endif 1014 endif
1015 else 1015 else
1016 if (!isempty (style)) 1016 if (! isempty (style))
1017 if (length (tmpwith) < sidx || isempty (tmpwith{sidx})) 1017 if (length (tmpwith) < sidx || isempty (tmpwith{sidx}))
1018 tmpwith{sidx} = sprintf ("with %s %s %s %s", 1018 tmpwith{sidx} = sprintf ("with %s %s %s %s",
1019 style, lw, lt, 1019 style, lw, lt,
1020 colorspec); 1020 colorspec);
1021 endif 1021 endif
1022 sidx ++; 1022 sidx ++;
1023 endif 1023 endif
1024 1024
1025 if (!isempty (pt)) 1025 if (! isempty (pt))
1026 if (! mono) 1026 if (! mono)
1027 if (strcmp (obj.markeredgecolor, "auto")) 1027 if (strcmp (obj.markeredgecolor, "auto"))
1028 colorspec = sprintf ("lc rgb \"#%02x%02x%02x\"", 1028 colorspec = sprintf ("lc rgb \"#%02x%02x%02x\"",
1029 round (255*color)); 1029 round (255*color));
1030 elseif (isnumeric (obj.markeredgecolor) && ! mono) 1030 elseif (isnumeric (obj.markeredgecolor) && ! mono)
1206 && all (obj.facecolor == 1))); 1206 && all (obj.facecolor == 1)));
1207 hidden_removal = false; 1207 hidden_removal = false;
1208 fputs (plot_stream, "set style increment default;\n"); 1208 fputs (plot_stream, "set style increment default;\n");
1209 if (flat_interp_edge && facecolor_none_or_white) 1209 if (flat_interp_edge && facecolor_none_or_white)
1210 withpm3d = false; 1210 withpm3d = false;
1211 withclause{data_idx} = sprintf ("with %s palette", style {1}); 1211 withclause{data_idx} = sprintf ("with %s palette", style{1});
1212 fputs (plot_stream, "unset pm3d\n"); 1212 fputs (plot_stream, "unset pm3d\n");
1213 if (all (obj.facecolor == 1)) 1213 if (all (obj.facecolor == 1))
1214 hidden_removal = true; 1214 hidden_removal = true;
1215 endif 1215 endif
1216 elseif (facecolor_none_or_white) 1216 elseif (facecolor_none_or_white)
1234 1234
1235 if (flat_interp_face && strcmp (obj.edgecolor, "flat")) 1235 if (flat_interp_face && strcmp (obj.edgecolor, "flat"))
1236 fprintf (plot_stream, 1236 fprintf (plot_stream,
1237 "set pm3d explicit at s %s %s corners2color c3;\n", 1237 "set pm3d explicit at s %s %s corners2color c3;\n",
1238 interp_str, dord); 1238 interp_str, dord);
1239 elseif (!facecolor_none_or_white) 1239 elseif (! facecolor_none_or_white)
1240 if (strcmp (obj.edgecolor, "none")) 1240 if (strcmp (obj.edgecolor, "none"))
1241 if (__gnuplot_has_feature__ ("transparent_surface") 1241 if (__gnuplot_has_feature__ ("transparent_surface")
1242 && isscalar (obj.facealpha)) 1242 && isscalar (obj.facealpha))
1243 fprintf (plot_stream, 1243 fprintf (plot_stream,
1244 "set style fill transparent solid %f;\n", 1244 "set style fill transparent solid %f;\n",
1402 1402
1403 endwhile 1403 endwhile
1404 1404
1405 ## This is need to prevent warnings for rotations in 3D plots, while 1405 ## This is need to prevent warnings for rotations in 3D plots, while
1406 ## allowing colorbars with contours. 1406 ## allowing colorbars with contours.
1407 if (nd == 2 || (data_idx > 1 && !view_map)) 1407 if (nd == 2 || (data_idx > 1 && ! view_map))
1408 fputs (plot_stream, "set pm3d implicit;\n"); 1408 fputs (plot_stream, "set pm3d implicit;\n");
1409 else 1409 else
1410 fputs (plot_stream, "set pm3d explicit;\n"); 1410 fputs (plot_stream, "set pm3d explicit;\n");
1411 endif 1411 endif
1412 1412
1774 x = flipud (fliplr (x)); 1774 x = flipud (fliplr (x));
1775 endif 1775 endif
1776 endfunction 1776 endfunction
1777 1777
1778 function spacing_spec = create_spacingspec (f, s, gp_term) 1778 function spacing_spec = create_spacingspec (f, s, gp_term)
1779 # The gnuplot default font size is 10, and default spacing is 1.25. 1779 ## The gnuplot default font size is 10, and default spacing is 1.25.
1780 # gnuplot has a concept of a figure global font, and sizes everything 1780 ## gnuplot has a concept of a figure global font, and sizes everything
1781 # appropriate to that, including the legend spacing. 1781 ## appropriate to that, including the legend spacing.
1782 # 1782 ##
1783 # This means that if an alternative size is used, gnuplot will use an 1783 ## This means that if an alternative size is used, gnuplot will use an
1784 # inappropriate spacing in the legend by default. 1784 ## inappropriate spacing in the legend by default.
1785 ##
1785 ## FIXME: Are fractional spacing specifications allowed? Or should this 1786 ## FIXME: Are fractional spacing specifications allowed? Or should this
1786 ## number be rounded? 1787 ## number be rounded?
1787 spc = s / 10 * 1.25; 1788 spc = s / 10 * 1.25;
1788 spacing_spec = sprintf ("spacing %d", spc); 1789 spacing_spec = sprintf ("spacing %d", spc);
1789 1790
1854 endif 1855 endif
1855 1856
1856 sidx = 1; 1857 sidx = 1;
1857 if (isempty (errbars)) 1858 if (isempty (errbars))
1858 if (isempty (lt)) 1859 if (isempty (lt))
1859 style {sidx} = ""; 1860 style{sidx} = "";
1860 else 1861 else
1861 style {sidx} = "lines"; 1862 style{sidx} = "lines";
1862 endif 1863 endif
1863 1864
1864 facesame = true; 1865 facesame = true;
1865 if (! isequal (pt, pt2) && isfield (obj, "markerfacecolor") 1866 if (! isequal (pt, pt2) && isfield (obj, "markerfacecolor")
1866 && !strcmp (obj.markerfacecolor, "none")) 1867 && ! strcmp (obj.markerfacecolor, "none"))
1867 if (strcmp (obj.markerfacecolor, "auto") 1868 if (strcmp (obj.markerfacecolor, "auto")
1868 || ! isnumeric (obj.markerfacecolor) 1869 || ! isnumeric (obj.markerfacecolor)
1869 || (isnumeric (obj.markerfacecolor) 1870 || (isnumeric (obj.markerfacecolor)
1870 && isequal (color, obj.markerfacecolor))) 1871 && isequal (color, obj.markerfacecolor)))
1871 if (! isempty (pt2)) 1872 if (! isempty (pt2))
1872 fprintf (plot_stream, " pointtype %s", pt2); 1873 fprintf (plot_stream, " pointtype %s", pt2);
1873 style {sidx} = strcat (style{sidx}, "points"); 1874 style{sidx} = strcat (style{sidx}, "points");
1874 endif 1875 endif
1875 if (isfield (obj, "markersize")) 1876 if (isfield (obj, "markersize"))
1876 fprintf (plot_stream, " pointsize %f", obj.markersize / 3); 1877 fprintf (plot_stream, " pointsize %f", obj.markersize / 3);
1877 endif 1878 endif
1878 else 1879 else
1879 facesame = false; 1880 facesame = false;
1880 if (! found_style) 1881 if (! found_style)
1881 fputs (plot_stream, " default"); 1882 fputs (plot_stream, " default");
1882 endif 1883 endif
1883 fputs (plot_stream, ";\n"); 1884 fputs (plot_stream, ";\n");
1884 if (! isempty (style {sidx})) 1885 if (! isempty (style{sidx}))
1885 sidx ++; 1886 sidx ++;
1886 idx ++; 1887 idx ++;
1887 else 1888 else
1888 fputs (plot_stream, ";\n"); 1889 fputs (plot_stream, ";\n");
1889 endif 1890 endif
1892 if (isnumeric (obj.markerfacecolor) && ! mono) 1893 if (isnumeric (obj.markerfacecolor) && ! mono)
1893 fprintf (plot_stream, " linecolor rgb \"#%02x%02x%02x\"", 1894 fprintf (plot_stream, " linecolor rgb \"#%02x%02x%02x\"",
1894 round (255*obj.markerfacecolor)); 1895 round (255*obj.markerfacecolor));
1895 endif 1896 endif
1896 if (! isempty (pt2)) 1897 if (! isempty (pt2))
1897 style {sidx} = "points"; 1898 style{sidx} = "points";
1898 fprintf (plot_stream, " pointtype %s", pt2); 1899 fprintf (plot_stream, " pointtype %s", pt2);
1899 endif 1900 endif
1900 if (isfield (obj, "markersize")) 1901 if (isfield (obj, "markersize"))
1901 fprintf (plot_stream, " pointsize %f", obj.markersize / 3); 1902 fprintf (plot_stream, " pointsize %f", obj.markersize / 3);
1902 endif 1903 endif
1903 endif 1904 endif
1904 endif 1905 endif
1905 if (isfield (obj, "markeredgecolor") 1906 if (isfield (obj, "markeredgecolor")
1906 && !strcmp (obj.markeredgecolor, "none")) 1907 && ! strcmp (obj.markeredgecolor, "none"))
1907 if (facesame && !isempty (pt) 1908 if (facesame && ! isempty (pt)
1908 && (strcmp (obj.markeredgecolor, "auto") 1909 && (strcmp (obj.markeredgecolor, "auto")
1909 || ! isnumeric (obj.markeredgecolor) 1910 || ! isnumeric (obj.markeredgecolor)
1910 || (isnumeric (obj.markeredgecolor) 1911 || (isnumeric (obj.markeredgecolor)
1911 && isequal (color, obj.markeredgecolor)))) 1912 && isequal (color, obj.markeredgecolor))))
1912 if (sidx == 1 && ((length (style {sidx}) == 5 1913 if (sidx == 1 && ((length (style{sidx}) == 5
1913 && strncmp (style{sidx}, "lines", 5)) || isempty (style {sidx}))) 1914 && strncmp (style{sidx}, "lines", 5)) || isempty (style{sidx})))
1914 if (! isempty (pt)) 1915 if (! isempty (pt))
1915 style {sidx} = strcat (style{sidx}, "points"); 1916 style{sidx} = strcat (style{sidx}, "points");
1916 fprintf (plot_stream, " pointtype %s", pt); 1917 fprintf (plot_stream, " pointtype %s", pt);
1917 endif 1918 endif
1918 if (isfield (obj, "markersize")) 1919 if (isfield (obj, "markersize"))
1919 fprintf (plot_stream, " pointsize %f", obj.markersize / 3); 1920 fprintf (plot_stream, " pointsize %f", obj.markersize / 3);
1920 endif 1921 endif
1922 else 1923 else
1923 if (! found_style) 1924 if (! found_style)
1924 fputs (plot_stream, " default"); 1925 fputs (plot_stream, " default");
1925 endif 1926 endif
1926 fputs (plot_stream, ";\n"); 1927 fputs (plot_stream, ";\n");
1927 if (!isempty (style {sidx})) 1928 if (! isempty (style{sidx}))
1928 sidx ++; 1929 sidx ++;
1929 idx ++; 1930 idx ++;
1930 else 1931 else
1931 fputs (plot_stream, ";\n"); 1932 fputs (plot_stream, ";\n");
1932 endif 1933 endif
1940 fprintf (plot_stream, " linecolor rgb \"#%02x%02x%02x\"", 1941 fprintf (plot_stream, " linecolor rgb \"#%02x%02x%02x\"",
1941 round (255*obj.markeredgecolor)); 1942 round (255*obj.markeredgecolor));
1942 endif 1943 endif
1943 endif 1944 endif
1944 if (! isempty (pt)) 1945 if (! isempty (pt))
1945 style {sidx} = "points"; 1946 style{sidx} = "points";
1946 fprintf (plot_stream, " pointtype %s", pt); 1947 fprintf (plot_stream, " pointtype %s", pt);
1947 endif 1948 endif
1948 if (isfield (obj, "markersize")) 1949 if (isfield (obj, "markersize"))
1949 fprintf (plot_stream, " pointsize %f", obj.markersize / 3); 1950 fprintf (plot_stream, " pointsize %f", obj.markersize / 3);
1950 endif 1951 endif
1953 else 1954 else
1954 style{1} = errbars; 1955 style{1} = errbars;
1955 fputs (plot_stream, " pointtype 0"); 1956 fputs (plot_stream, " pointtype 0");
1956 endif 1957 endif
1957 1958
1958 if (! found_style && isempty (style {1})) 1959 if (! found_style && isempty (style{1}))
1959 fputs (plot_stream, " default"); 1960 fputs (plot_stream, " default");
1960 endif 1961 endif
1961 1962
1962 fputs (plot_stream, ";\n"); 1963 fputs (plot_stream, ";\n");
1963 1964
2417 endfor 2418 endfor
2418 endif 2419 endif
2419 endif 2420 endif
2420 endfor 2421 endfor
2421 2422
2422 ## Prepend @ to things things like _0^x or _{-100}^{100} for 2423 ## Prepend @ to things like _0^x or _{-100}^{100} for alignment.
2423 ## alignment But need to put the shorter of the two arguments first. 2424 ## But need to put the shorter of the two arguments first.
2424 ## Carful of nested {} and unprinted characters when defining 2425 ## Careful of nested {} and unprinted characters when defining
2425 ## shortest.. Don't have to worry about things like ^\theta as they 2426 ## shortest.. Don't have to worry about things like ^\theta as they
2426 ## are already converted to ^{/Symbol q}. 2427 ## are already converted to ^{/Symbol q}.
2427 2428
2428 ## FIXME: This is a mess... Is it worth it just for a "@" character? 2429 ## FIXME: This is a mess... Is it worth it just for a "@" character?
2429 2430
2430 [s, m] = regexp (str,'[_\^]','start','matches'); 2431 [s, m] = regexp (str,'[_\^]','start','matches');
2502 endfunction 2503 endfunction
2503 2504
2504 function l = length_string (s) 2505 function l = length_string (s)
2505 l = length (s) - length (strfind (s,'{')) - length (strfind (s,'}')); 2506 l = length (s) - length (strfind (s,'{')) - length (strfind (s,'}'));
2506 m = regexp (s, '/([\w-]+|[\w-]+=\d+)', 'matches'); 2507 m = regexp (s, '/([\w-]+|[\w-]+=\d+)', 'matches');
2507 if (!isempty (m)) 2508 if (! isempty (m))
2508 l = l - sum (cellfun ("length", m)); 2509 l = l - sum (cellfun ("length", m));
2509 endif 2510 endif
2510 endfunction 2511 endfunction
2511 2512
2512 function sym = __setup_sym_table__ () 2513 function sym = __setup_sym_table__ ()
2540 sym.varphi = '{/Symbol j}'; # Not in OpenGL 2541 sym.varphi = '{/Symbol j}'; # Not in OpenGL
2541 sym.kappa = '{/Symbol k}'; 2542 sym.kappa = '{/Symbol k}';
2542 sym.lambda = '{/Symbol l}'; 2543 sym.lambda = '{/Symbol l}';
2543 sym.mu = '{/Symbol m}'; 2544 sym.mu = '{/Symbol m}';
2544 sym.nu = '{/Symbol n}'; 2545 sym.nu = '{/Symbol n}';
2545 sym.o = '{/Symbol o}'; 2546 sym.o = '{/Symbol o}';
2546 sym.pi = '{/Symbol p}'; 2547 sym.pi = '{/Symbol p}';
2547 sym.theta = '{/Symbol q}'; 2548 sym.theta = '{/Symbol q}';
2548 sym.rho = '{/Symbol r}'; 2549 sym.rho = '{/Symbol r}';
2549 sym.sigma = '{/Symbol s}'; 2550 sym.sigma = '{/Symbol s}';
2550 sym.tau = '{/Symbol t}'; 2551 sym.tau = '{/Symbol t}';
2616 sym.Rightarrow = '{/Symbol \336}'; 2617 sym.Rightarrow = '{/Symbol \336}';
2617 sym.Downarrow = '{/Symbol \337}'; # Not in OpenGL 2618 sym.Downarrow = '{/Symbol \337}'; # Not in OpenGL
2618 sym.diamond = '{/Symbol \340}'; # Not in OpenGL 2619 sym.diamond = '{/Symbol \340}'; # Not in OpenGL
2619 sym.copyright = '{/Symbol \343}'; 2620 sym.copyright = '{/Symbol \343}';
2620 sym.lfloor = '{/Symbol \353}'; 2621 sym.lfloor = '{/Symbol \353}';
2621 sym.lceil = '{/Symbol \351}'; 2622 sym.lceil = '{/Symbol \351}';
2622 sym.rfloor = '{/Symbol \373}'; 2623 sym.rfloor = '{/Symbol \373}';
2623 sym.rceil = '{/Symbol \371}'; 2624 sym.rceil = '{/Symbol \371}';
2624 sym.int = '{/Symbol \362}'; 2625 sym.int = '{/Symbol \362}';
2625 endfunction 2626 endfunction
2626 2627
2627 function retval = __do_enhanced_option__ (enhanced, obj) 2628 function retval = __do_enhanced_option__ (enhanced, obj)
2628 retval = ""; 2629 retval = "";