bugGNU Octave - Bugs: bug #52700, plotyy legend in reverse order

 
 

bug #52700: plotyy legend in reverse order

Submitted by:  None
Submitted on:  Tue 19 Dec 2017 09:53:26 PM UTC  
 
Category: PlottingSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Incorrect Result
Status: FixedAssigned to: None
Originator Name: BlindcurrentOriginator Email: -unavailable-
Open/Closed: ClosedRelease: 4.2.1
Operating System: Microsoft Windows

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

(Jump to the original submission Jump to the original submission)

Thu 21 Dec 2017 03:46:38 PM UTC, comment #6:

Thank you for your suggestions and explanations. Assigning a handle to each curve and specifying which ones should appear in the legend is a very good idea to make sure the right lines appear in the legend in the right order.

Anonymous
Wed 20 Dec 2017 05:26:42 PM UTC, 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.

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

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

(file #42691)

Rik <rik5>
Project Administrator
Wed 20 Dec 2017 05:04:04 PM UTC, comment #4:

It's not uncommon for a bug to manifest differently for different systems. The first step is confirming the bug and trying to characterize it. I'm testing on linux. Typically, the more inconsistent bugs are related to a bad pointer or index, i.e., some kind of randomness about it.

Is it certain that this works in Matlab? The example generates an initial plot with simple lines on it:

So, I take it that means AX(1) has one plot object and AX(2) has one plot object. Note that the left axis AX(1) is highlighted with a thin cyan line (and the right axis AX(2) a thin brown line).

At that point hold is turned on.

Next, a second and third plot object are added to the first axis:

and a second plot object is added to the second axis:

So, at that point we have 3 plot objects on AX(1) and 2 plot objects on AX(2).

Now, we specify just two legend entries for that first axis:

So, my suspicion is that there is something not quite programmed consistently with regard to what to do in that situation. On my system, somehow the legend example line is being grabbed for the first legend entry.

How about if I make the legend instead:

I then see what looks like proper legend labeling and samples. [BTW, that dotted green line is extremely difficult to see on my system. The ratio of white space to green dot is rather large.]

The initial plot of lines from zero to two-pi seems somewhat extraneous. One could instead do:

After those changes, I then see what I think you originally had in mind.

Anyway, what I see from your original code kind of makes sense in terms of the legend. The 'sine' text entry is actually labeling that initial flat line from zero to two-pi. The 'cosine' text entry is actually labeling the second plot object which is the sine function. So, the question is, Why is your system producing one in which the first line is red, weight 2?

Oh, you are testing on Version 4.2.1? This issue may have been fixed already. As I said, I recall a group of us having debugged some of this plotyy legend behavior in the not-too-distant past. It's probably difficult for you to build the development version for Windows. (I know nothing about the Octave-for-Windows build process or who archives what where.)

Dan Sebald <sebald>
Wed 20 Dec 2017 10:09:37 AM UTC, comment #3:

I don't quite understand your statement about the colours of the legend line examples being wrong. They appear as blue and red just like they are supposed to. Do you see the mismatch in the attached figure files, or did you run the code on your computer?

Further, I did not find the issue with the reversed legend order reported in other bug reports, including the ones you cite.

Anonymous
Tue 19 Dec 2017 11:31:39 PM UTC, comment #2:

Actually there is quite a history for this one:

https://savannah.gnu.org/bugs/?46835
https://savannah.gnu.org/bugs/?50497
https://savannah.gnu.org/bugs/?51263
https://savannah.gnu.org/bugs/?51732

This may be a duplicate.

Dan Sebald <sebald>
Tue 19 Dec 2017 11:27:48 PM UTC, comment #1:

The legend line examples aren't matching here. cosine comes out blue (correct), while sine comes out thin cyan (not red). Both for gnuplot and FLTK. This reminds me of some kind of plot bug a few months back in which we had multiple colors on multiple axes and at some point we decide it was good enough because of the confusion it created.

Dan Sebald <sebald>
Tue 19 Dec 2017 09:53:26 PM UTC, original submission:

A legend added to a plot created with the plotyy command comes out wrong when it is located in the northeast. In this one location, the order of the plotstyle entries (not the string labels) is reversed.

Please see this example code together with the attached figures:

The legend is correct in all locations other than northeast, including all the outside versions.

I am using Windows 7 and have installed Octave using the w64 installer. I have found the issue to occur in the versions 4.2.0 and 4.2.1.

This bug may be related to https://savannah.gnu.org/bugs/?50497 or https://savannah.gnu.org/bugs/?35314, but neither of these covers the location dependence.

Final note: I do not need a patch, because applying it is beyond my expertise. I am only reporting it so that it can be fixed in a future version of Octave. In the meantime, my workaround is to plot the graphs in reverse order so that the legend comes out right.

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

Attached Files
file #42691:  tst_plotyy2.m added by rik5 (575B - text/x-matlab)
file #42686:  northeast.png added by None (146KiB - image/png)
file #42687:  east.png added by None (146KiB - image/png)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by rik5 (Updated the item)
  • -unavailable- added by sebald (Posted a comment)
  • -unavailable- added by None (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 5 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Wed 20 Dec 2017 05:26:42 PM UTCrik5Attached File-=>Added tst_plotyy2.m, #42691
      StatusNone=>Fixed
      Open/ClosedOpen=>Closed
    Tue 19 Dec 2017 09:53:26 PM UTCNoneAttached File-=>Added northeast.png, #42686
      Attached File-=>Added east.png, #42687

    Back to the top


    Powered by Savane 3.1-cleanup1