[Top][All Lists]

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

[Octave-task-tracker] [task #14243] Rewrite legend.m

From: Rik
Subject: [Octave-task-tracker] [task #14243] Rewrite legend.m
Date: Sat, 9 Nov 2019 21:44:13 -0500 (EST)
User-agent: Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko

Update of task #14243 (project octave):

                Category:                    None => Wish                   
                  Status:                    None => In Progress            


Follow-up Comment #10:

@Pantxo: I reviewed the code a bit (not fully).  It's quite good in that it
solves the longstanding issue where the legend position was not updated with
size changes to the axes.  For example,

plot (1:10, 'o-');
legend ({"legend text"});
title ({"line 1"; "line 2"; "line 3"; "line 4"});

The hack to handle gnuplot is ugly, but I think acceptable.

Some things I did notice:

1) Performance is much slower (~1/2)

Try this code

tic; demo ("legend", 31); toc

With the new code it took 6.7 seconds, while the old code took just 3.0
seconds.  Either one is pretty unacceptable, but users will really notice a
nearly 7 second delay.

You could use the Octave profiler to see where the code is spending its time. 
I think the old version of legend.m used lots of tricks such as turning the
visibility of the legend off while it was being constructed and only turning
it on at the end, and disabling the listener functions while it was updating.

2) legend key for line objects

The old legend key for a line object had the line, in the correct color, with
the marker displayed in the midpoint of the line.  This is the style Matlab
uses as well and I like it.  The style in this patch, with a marker on the
left and on the right and a line connecting them, seems too busy.

3) legend ("text") fails

The most common calling form fails.  Example code:

octave:1> plot (1:10, 'o-')
octave:2> legend ('abc')
error: scalar cannot be indexed with {
error: called from
    legend>__legend_textitem_array__ at line 814 column 16
    legend>__legend_update_layout__ at line 623 column 27
    legend at line 201 column 5

4) No warning about extra arguments to legend


demo legend 26

This should print a warning about calling legend incorrectly.

5) Support old multiple output calling form.

The old calling form was

[HLEG, HLEG_OBJ, HPLOT, LABELS] = legend (...)

If you use this format in Matlab, it returns the data it can, HLEG and HPLOT,
and empty objects for HLEG_OBJ and LABELS.  It might be nice to replicate that
since it will be a big step change for users to switch all of their code to
the new syntax.

[HLEG, HPLOT] = legend (...)

6) stray keyboard statement

There is a stray keyboard statement at line 341 that you must have been using
for testing.  I just commented it out in order to run tests.


Reply to this item at:


  Message sent via Savannah

reply via email to

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