help-octave
[Top][All Lists]
Advanced

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

Re: Legend help


From: Quentin Spencer
Subject: Re: Legend help
Date: Fri, 10 Nov 2006 14:09:18 -0600
User-agent: Thunderbird 1.5.0.8 (X11/20061107)

John W. Eaton wrote:
On  7-Nov-2006, Dmitri A. Sergatskov wrote:

| Since we are on the subject.
| | The current version of legend fails if called before the first invocation of
| gnuplot:
| | octave:1> legend("junk1")
| error: invalid row index = 0
| error: evaluating argument list element number 1
| error: evaluating argument list element number 1
| error: evaluating prefix operator `!' near line 208, column 7
| error: if: error evaluating conditional expression
| error: evaluating if command near line 208, column 3
| error: called from `legend' in file `/arch1/dima/incoming/legend.m'
| octave:1> plot(rand(5))
| octave:2> legend("junk1")
| | (works now) | | octave:3> | | I do not think it is a very serious problem, but want to let you know...

I just checked in a largeish patch that fixes this problem and adds
legend.m to Octave (it should probably be removed from Octave Forge
now).  Instead of the error above, you should see

  octave:1> legend ("boxon")
  octave:2> legend ("foo", "bar")
  warning: legend: plot data is empty; setting key labels has no effect

The "boxon" setting will affect subsequent plots.  Setting key labels
with legend should happen after plotting data.

Instead of trying to extract the current key labels by saving the
current plot state and parsing the output with awk, Octave now saves
the key labels in a structure and uses that to add labels to the plot
as needed.  The legend function now just modifies the data structure.
As this change is relatively invasive, it would be good if people
could do some testing with the current plot code in Octave's CVS
archive.

I think this is the right approach for the legend function. I've removed the old legend.m function from octave-forge, and I've done some testing of the new one. The first thing I noticed is that it doesn't seem to be marked as command. Doesn't the

## PKG_ADD mark_as_command legend

in legend.m make it automatically marked at octave startup? I'm not sure why it's not working for me. Here's another thing I noticed--this was probably the case before, but all the same it would be nice to fix. In addition to storing the legend strings, attributes like position and use of box should be stored, so that the following code results in the legend being in the upper left with a box:

octave:1> plot(rand(10,2));
octave:2> legend('test1','test2',2);
octave:3> legend('boxon');
octave:4> legend('hide');
octave:5> legend('show');

Otherwise, I think it works pretty well. Also, if we're interested in having the same default settings as Matlab (not that I care much in this case), the default is 'boxon'.

Quentin



reply via email to

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