changeset 14236:35903f035390

Escaping strings for legend entries are handled by __go_draw_axes__. Bug # 35330. * __pltopt__.m: Don't escape strings. * legend.m: Add demo and test.
author Ben Abbott <bpabbott@mac.com>
date Thu, 19 Jan 2012 19:48:13 -0500
parents 921b15c13adc
children 11949c9795a0
files scripts/plot/legend.m scripts/plot/private/__pltopt__.m
diffstat 2 files changed, 25 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/plot/legend.m	Thu Jan 19 18:47:38 2012 -0500
+++ b/scripts/plot/legend.m	Thu Jan 19 19:48:13 2012 -0500
@@ -980,6 +980,13 @@
 %!demo
 %! clf
 %! x = 0:1;
+%! plot (x, x, ";\alpha;",
+%!       x, 2*x, ";\beta=2\alpha;",
+%!       x, 3*x, ";\gamma=3\alpha;")
+
+%!demo
+%! clf
+%! x = 0:1;
 %! plot (x, x, ";I am Blue;", x, 2*x, x, 3*x, ";I am Red;")
 %! title ("Blue and Green keys, with Green mising")
 
@@ -1180,3 +1187,20 @@
 %! [ax, h1, h2] = plotyy (x, y1, x, y2);
 %! legend ("Blue", "Green", "location", "south");
 
+%!test
+%! x = 0:10;
+%! y = rand (size (x));
+%! displayname = '\alpha_\beta \delta^\theta';
+%! displayname1 = "";
+%! displayname2 = "";
+%! figure (1, "visible", false)
+%! unwind_protect
+%!   h = plot (x, y, sprintf (";%s;", displayname));
+%!   displayname1 = get (h, "displayname")
+%!   hlegend = legend (h, displayname, "location", "south");
+%!   displayname2 = get (h, "displayname")
+%! unwind_protect_cleanup
+%!   close (gcf;
+%! end_unwind_protect
+%! assert (displayname1, displayname)
+%! assert (displayname2, displayname)
--- a/scripts/plot/private/__pltopt__.m	Thu Jan 19 18:47:38 2012 -0500
+++ b/scripts/plot/private/__pltopt__.m	Thu Jan 19 19:48:13 2012 -0500
@@ -206,7 +206,7 @@
       elseif (topt == ";")
         t = index (opt(2:end), ";");
         if (t)
-          options.key = undo_string_escapes (opt(2:t));
+          options.key = opt(2:t);
           n = t+1;
         else
           if (err_on_invalid)