diff scripts/plot/private/__go_draw_axes__.m @ 13979:f35b593688a5

Changing the legend's interpreter property should be inherited by the legend's labels (Fix bug #34342). * scripts/plot/__go_draw_axes__.m: Add no_tex() to escape "_" & "^". * scripts/plot/legend.m: Fix the text labels updater. Warn if extra entries are present. Add demos and fix others.
author Ben Abbott <bpabbott@mac.com>
date Fri, 02 Dec 2011 19:42:42 -0500
parents bebd3ae908cb
children 0b94080d2b0f
line wrap: on
line diff
--- a/scripts/plot/private/__go_draw_axes__.m	Fri Dec 02 18:50:56 2011 -0500
+++ b/scripts/plot/private/__go_draw_axes__.m	Fri Dec 02 19:42:42 2011 -0500
@@ -441,6 +441,7 @@
     while (! isempty (kids))
 
       obj = get (kids(end));
+
       if (isfield (obj, "units"))
         units = obj.units;
         unwind_protect
@@ -2302,10 +2303,38 @@
         warning ("latex markup not supported for text objects");
         warned_latex = true;
       endif
+    elseif (enhanced)
+      str = no_super_sub_scripts (str);
     endif
   endif
 endfunction
 
+function str = no_super_sub_scripts (str)
+  if (iscellstr (str))
+    labels = str;
+  else
+    labels = cellstr (str);
+  endif
+  for marker = "_^" 
+    for m = 1 : numel(labels)
+      n1 = strfind (labels{m}, sprintf ("\\%s", marker));
+      n2 = strfind (labels{m}, marker);
+      if (! isempty (n1))
+        n1 = n1 + 1;
+        n2 = setdiff (n2, n1);
+      end
+      for n = n2
+        labels{m} = [labels{m}(1:n2-1), "\\", labels{m}(n2:end)];
+      endfor
+    endfor
+  endfor
+  if (iscellstr (str))
+    str = labels;
+  else
+    str = char (labels);
+  endif
+endfunction
+
 function str = __tex2enhanced__ (str, fnt, it, bld)
   persistent sym = __setup_sym_table__ ();
   persistent flds = fieldnames (sym);