octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #57523] [Feature Request] legend should accept


From: Guillaume
Subject: [Octave-bug-tracker] [bug #57523] [Feature Request] legend should accept 2-letter abbreviations for "Location" property
Date: Mon, 10 May 2021 16:50:58 -0400 (EDT)
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Firefox/68.0

Follow-up Comment #5, bug #57523 (project octave):

Sorry, I might have written that code as a way to describe my findings from
comment #2 without running it.

I thought the code would go in the update_legend_position subfunction:


diff -r e8e9f815945a scripts/plot/appearance/legend.m
--- a/scripts/plot/appearance/legend.m  Sun Apr 25 18:45:46 2021 +0200
+++ b/scripts/plot/appearance/legend.m  Mon May 10 21:43:37 2021 +0100
@@ -1417,6 +1417,24 @@
   persistent vmargin = 6;
 
   location = get (hl, "location");
+
+  locations = {"East", "EastOutside", "North", "NorthEast", ...
+    "NorthEastoOutside", "NorthOutside", "NorthWest", "NorthWestOutside",
...
+    "South", "SouthEast",  "SouthEastOutside", "SouthOutside", "SouthWest",
...
+    "SouthWestOutside", "West",  "WestOutside"};
+  acronyms = cellfun (@(x) tolower (x(x>='A' & x<='Z')),  locations, ...
+    "UniformOutput", false);
+  locations = tolower (locations);
+  acr2loc = cell2struct (locations, acronyms, 2);
+  if (isfield (acr2loc, location))
+    location = acr2loc.(location);
+  endif
+  location = location(~isspace (location));
+  idx = find (strncmp (location, locations, numel (location)));
+  if (isscalar (idx))
+    location = locations{idx};
+  endif
+
   outside = strcmp (location(end-3:end), "side");
   if (outside)
     location = location(1:end-7);


but that's not enough and you are probably right it should go in parse_opts. I
will look into it.

    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?57523>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]