[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Variable name in legend of Plot.
From: |
niles |
Subject: |
Re: Variable name in legend of Plot. |
Date: |
Wed, 04 Oct 95 09:26:10 -0400 |
>I would like to get the variable name in legend of a plot.
>
>Although I noticed looking through the ".m" files that:
>
># The legend may be fixed to include the name of the variable
># plotted in some future version of Octave.
>
>I thought I would ask anyway.
>
>I would like to be able to change "line 1" to my variable name. Has
>anyone done this? If so, can you please share with me what I need to
>do to accomplish this? Thanks.
Here's a patch to plot_opt.m that will give this ability.
plot(x,y,';Cool_Signal;')
'line 1' will be replaced by Cool_Signal. However, currently it
doesn't work with spaces. The problem lies in:
[char, opt] = sscanf (opt, "%c %s");
'opt' will only get the rest of the format string up to a space. This
will all be fixed in the next official version of octave, which will
support indexing of arrays.
Good Luck,
Rick Niles.
-------------------------
*** plot_opt.m.orig Fri Apr 21 22:45:49 1995
--- plot_opt.m Mon Sep 25 22:44:10 1995
*************** function fmt = plot_opt (caller, opt)
*** 42,47 ****
--- 42,48 ----
# "n" with n in 1-6 (wraps at 8), plot color
# "nm" with m in 1-6 (wraps at 6), point style (only valid with "@" or
"-@")
# "c" where c is one of ["r", "g", "b", "m", "c", "w"] colors.
+ # ";title;" where "title" is the label for the key.
#
# Special points formats:
#
*************** function fmt = plot_opt (caller, opt)
*** 70,75 ****
--- 71,77 ----
set_steps = 0;
set_boxes = 0;
set_errbars = 0;
+ set_key = 0;
more = 1;
WITH = "w";
*************** function fmt = plot_opt (caller, opt)
*** 82,87 ****
--- 84,90 ----
IMPULSES = "i";
STEPS = "s";
ERRORBARS = "e";
+ TITLE = "title";
if (nargin != 2)
usage ("plot_opt (opt)");
*************** function fmt = plot_opt (caller, opt)
*** 165,170 ****
--- 168,194 ----
set_points = 1;
set_symbol = 1;
symbol = "4";
+ elseif (strcmp (char, ";")) %% title mode.
+ set_key = 1;
+ working = 1;
+ key_title = "";
+ while (working)
+ if (max (size (opt)) > 1)
+ [char, opt] = sscanf (opt, "%c %s");
+ else
+ char = opt;
+ if(!strcmp(char,";"))
+ error(sprintf ("Unfinished key label in %s", caller));
+ end
+ more = 0;
+ working = 0;
+ endif
+ if strcmp (char, ";")
+ working = 0;
+ else
+ key_title = strcat (key_title, char);
+ endif
+ endwhile
else
error (sprintf ("%s: unrecognized format character %s", caller, char));
endif
*************** function fmt = plot_opt (caller, opt)
*** 211,214 ****
--- 235,241 ----
fmt = strcat (fmt, " 1 ", symbol);
endif
+ if (set_key)
+ fmt = strcat (fmt, " ", TITLE, ' "', key_title, '" ');
+ endif
endfunction