changeset 30253:20fd3c03fd74

Add new plot marker styles '|' and '_' (bug #61350) * NEWS: Announce addition. * gl-render.cc (make_marker_list): Add instructions for drawing '|' and '_' markers. * graphics.cc (radio_values::radio_values): Add special case in constructor from string of options to parse '|||' and return value '|'. * graphics.in.h (line, patch, scatter, surface): Add '|' and '_' to marker property for graphics objects which have this property. * __pltopt__.m: Add '|' and '_' to list of possible markers in input validation. * __gnuplot_draw_axes__.m: Add FIXME note about implementing these two markers in gnuplot. There doesn't seem to be an easy way to do this as it is not one of the defined point styles.
author Rik <rik@octave.org>
date Wed, 27 Oct 2021 15:07:52 -0700
parents 774d6edb4cae
children 0fc950301a50
files NEWS libinterp/corefcn/gl-render.cc libinterp/corefcn/graphics.cc libinterp/corefcn/graphics.in.h scripts/plot/util/__pltopt__.m scripts/plot/util/private/__gnuplot_draw_axes__.m
diffstat 6 files changed, 41 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/NEWS	Wed Oct 27 15:02:20 2021 -0400
+++ b/NEWS	Wed Oct 27 15:07:52 2021 -0700
@@ -129,6 +129,9 @@
 `"interpreter"` property and axes objects' `"ticklabelinterpreter"`.
 Type `doc "latex interpreter"` for further info.
 
+- The `"Marker"` property for plot objects now accepts `|` which draws
+a vertical line or `_` which draws a horizontal line.
+
 - The `FMT` format argument for plot commands now accepts long forms for
 color names which may be more understandable than the existing
 one-letter codes.  For example, the RGB value `[0 0 0]` can now be
--- a/libinterp/corefcn/gl-render.cc	Wed Oct 27 15:02:20 2021 -0400
+++ b/libinterp/corefcn/gl-render.cc	Wed Oct 27 15:07:52 2021 -0700
@@ -4687,7 +4687,8 @@
 
     char c = marker[0];
 
-    if (filled && (c == '+' || c == 'x' || c == '*' || c == '.'))
+    if (filled && (c == '+' || c == 'x' || c == '*' || c == '.'
+                   || c == '|' || c == '_'))
       return 0;
 
     unsigned int ID = m_glfcns.glGenLists (1);
@@ -4711,6 +4712,18 @@
         m_glfcns.glVertex2d (0, sz/2);
         m_glfcns.glEnd ();
         break;
+      case '|':
+        m_glfcns.glBegin (GL_LINES);
+        m_glfcns.glVertex2d (0, -sz/2);
+        m_glfcns.glVertex2d (0, sz/2);
+        m_glfcns.glEnd ();
+        break;
+      case '_':
+        m_glfcns.glBegin (GL_LINES);
+        m_glfcns.glVertex2d (-sz/2, 0);
+        m_glfcns.glVertex2d (sz/2, 0);
+        m_glfcns.glEnd ();
+        break;
       case 'x':
         m_glfcns.glBegin (GL_LINES);
         m_glfcns.glVertex2d (-sz/2, -sz/2);
--- a/libinterp/corefcn/graphics.cc	Wed Oct 27 15:02:20 2021 -0400
+++ b/libinterp/corefcn/graphics.cc	Wed Oct 27 15:07:52 2021 -0700
@@ -1315,7 +1315,14 @@
 
       std::string t = opt_string.substr (beg, end-beg);
 
-      // Might want more error checking here...
+      // Special case for '|' symbol itself
+      if (t.empty () && opt_string[beg] == '|')
+        {
+          t = '|';
+          end++;
+        }
+
+      // Might want more error checking on parsing default value...
       if (t[0] == '{')
         {
           t = t.substr (1, t.length () - 2);
--- a/libinterp/corefcn/graphics.in.h	Wed Oct 27 15:02:20 2021 -0400
+++ b/libinterp/corefcn/graphics.in.h	Wed Oct 27 15:07:52 2021 -0700
@@ -4400,7 +4400,7 @@
       radio_property linejoin , "{round}|miter|chamfer"
       radio_property linestyle , "{-}|--|:|-.|none"
       double_property linewidth , 0.5
-      radio_property marker , "{none}|+|o|*|.|x|s|square|d|diamond|^|v|>|<|p|pentagram|h|hexagram"
+      radio_property marker , "{none}|+|o|*|.|x|||_|s|square|d|diamond|^|v|>|<|p|pentagram|h|hexagram"
       color_property markeredgecolor , color_property (radio_values ("{auto}|none"), color_values (0, 0, 0))
       color_property markerfacecolor , color_property (radio_values ("auto|{none}"), color_values (0, 0, 0))
       double_property markersize , 6
@@ -4991,7 +4991,7 @@
       array_property facevertexcdata u , Matrix ()
       radio_property linestyle , "{-}|--|:|-.|none"
       double_property linewidth , 0.5
-      radio_property marker , "{none}|+|o|*|.|x|s|square|d|diamond|^|v|>|<|p|pentagram|h|hexagram"
+      radio_property marker , "{none}|+|o|*|.|x|||_|s|square|d|diamond|^|v|>|<|p|pentagram|h|hexagram"
       color_property markeredgecolor , color_property (radio_values ("none|{auto}|flat"), color_values (0, 0, 0))
       color_property markerfacecolor , color_property (radio_values ("{none}|auto|flat"), color_values (0, 0, 0))
       double_property markersize , 6
@@ -5251,7 +5251,7 @@
       double_property linewidth , 0.5
       array_property longitudedata , Matrix ()
       string_property longitudedatasource , ""
-      radio_property marker , "{o}|+|*|.|x|s|square|d|diamond|^|v|>|<|p|pentagram|h|hexagram|none"
+      radio_property marker , "{o}|+|*|.|x|||_|s|square|d|diamond|^|v|>|<|p|pentagram|h|hexagram|none"
       double_property markeredgealpha , 1.0
       color_property markeredgecolor , color_property (radio_values ("{flat}|none"), color_values (0, 0, 0))
       double_property markerfacealpha , 1.0
@@ -5487,7 +5487,7 @@
       radio_property facenormalsmode u , "{auto}|manual"
       radio_property linestyle , "{-}|--|:|-.|none"
       double_property linewidth , 0.5
-      radio_property marker , "{none}|+|o|*|.|x|s|square|d|diamond|^|v|>|<|p|pentagram|h|hexagram"
+      radio_property marker , "{none}|+|o|*|.|x|||_|s|square|d|diamond|^|v|>|<|p|pentagram|h|hexagram"
       color_property markeredgecolor , color_property (radio_values ("none|{auto}|flat"), color_values (0, 0, 0))
       color_property markerfacecolor , color_property (radio_values ("{none}|auto|flat"), color_values (0, 0, 0))
       double_property markersize , 6
--- a/scripts/plot/util/__pltopt__.m	Wed Oct 27 15:02:20 2021 -0400
+++ b/scripts/plot/util/__pltopt__.m	Wed Oct 27 15:07:52 2021 -0700
@@ -84,6 +84,8 @@
 ## @itemx @qcode{"*"}
 ## @itemx @qcode{"."}
 ## @itemx @qcode{"x"}
+## @itemx @qcode{"|"}
+## @itemx @qcode{"_"}
 ## @itemx @qcode{"s"}
 ## @itemx @qcode{"d"}
 ## @itemx @qcode{"^"}
@@ -165,7 +167,7 @@
       have_linestyle = true;
       options.linestyle = topt;
     ## Markers
-    elseif (any (topt == "+o*.xsd^v><ph"))
+    elseif (any (topt == "+o*.x|_sd^v><ph"))
       have_marker = true;
       ## Check for long form marker styles
       if (any (topt == "sdhp"))
--- a/scripts/plot/util/private/__gnuplot_draw_axes__.m	Wed Oct 27 15:02:20 2021 -0400
+++ b/scripts/plot/util/private/__gnuplot_draw_axes__.m	Wed Oct 27 15:07:52 2021 -0700
@@ -2079,6 +2079,15 @@
     switch (obj.marker)
       case "+"
         pt = pt2 = "1";
+      ## FIXME: It's not clear how to add support for these markers in gnuplot
+      #{
+      case "|"
+        pt = "1";
+        pt2 = "1";
+      case "_"
+        pt = "1";
+        pt2 = "1";
+      #}
       case "o"
         pt = "6";
         pt2 = "7";