[Top][All Lists]

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

[Octave-bug-tracker] [bug #52700] plotyy legend in reverse order

From: Rik
Subject: [Octave-bug-tracker] [bug #52700] plotyy legend in reverse order
Date: Wed, 20 Dec 2017 12:26:43 -0500 (EST)
User-agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:55.0) Gecko/20100101 Firefox/55.0

Update of bug #52700 (project octave):

                  Status:                    None => Fixed                  
             Open/Closed:                    Open => Closed                 


Follow-up Comment #5:

I also agree that the script is confusing becasue there are 5 line objects for
labeling spread across two axes.  I re-wrote the script to be a little clearer
and avoid greating the initial two line objects in the plotyy command.


#[AX,H1,H2]=plotyy([0 2*pi],[0 0], [0 2*pi],[0 0]);   # original
[AX,H1,H2]=plotyy(x, sine, x, 1.1*sine);
hold on
#plot(x,sine,'parent',AX(1),'b','linewidth',2);       # original
set (H1, 'color','b', 'linewidth', 2);
#plot(x,cosine,'parent',AX(1),'r','linewidth',2);     # original
plot (AX(1), x,cosine, 'r', 'linewidth', 2);
#plot(x,1.1*sine,'parent',AX(2),'g:','linewidth',1);  # original
set (H2, 'color', 'g', 'linestyle', ':', 'linewidth', 1);


This is attached as file tst_plotyy2.m.

Note that on 4.2.1 the new script no longer puts a thin line into the legend,
but the legend objects are reversed such that the sine label is on the cosine
color and vice versa.  On the development branch this has been fixed and
everything works correctly.  For that reason I'm going to mark this report as
fixed and close it.

Also, even in 4.2.1 you can get this to work by simply being explicit about
what you want.  If you know the particular objects you want to label, just
tell the legend function what those are, rather than having it try to guess,
and guess incorrectly.

In this case, the handle for the sine plot is already in H1 so change the
cosine plot command to make sure you capture the handle

H3 = plot (AX(1), x,cosine, 'r', 'linewidth', 2);

And then when you call legend give it the objects you want to label

leg=legend([H1, H3], 'sine', 'cosine');

(file #42691)

Additional Item Attachment:

File name: tst_plotyy2.m                  Size:0 KB


Reply to this item at:


  Message sent via/by Savannah

reply via email to

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