bugGNU Octave - Bugs: bug #44829, Separate legends for each plotyy...

 
 

bug #44829: Separate legends for each plotyy axis not possible

Submitted by:  Mattias Linde <linde>
Submitted on:  Tue 14 Apr 2015 08:15:11 AM UTC  
 
Category:  Plotting Severity:  3 - Normal
Priority:  3 - Low Item Group:  Regression
Status:  Confirmed Assigned to:  None
Originator Name:  Open/Closed:  Open
Release:  dev Operating System:  GNU/Linux

Add a New Comment (Rich Markup)
   

You are not logged in

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

 

Fri 22 Dec 2017 04:32:17 PM UTC, comment #3: 

I just rewrote legend and plotyy on the development branch.  This issue is still there, but I've marked the priority as low.  Most people want to be able to supply the labels to a plotyy legend in one statement.  Hence, legend treats both axes of a plotyy as a single object and you are only allowed to create one legend for the entire thing.  I suppose this could be changed, but if you really need this capability it might be easier to use text objects which you could position at will.

Rik <rik5>
Project Administrator
Thu 17 Nov 2016 10:39:47 AM UTC, comment #2: 

This bug is still present in the current dev 4.3.0 (39f39eb4e476).

I filed task #14243 about rewriting legend.m

Pantxo Diribarne <pantxo>
Project Member
Thu 16 Apr 2015 04:46:34 PM UTC, comment #1: 

Confirmed.  I'm bumping the release to dev since this bug is still present in the latest code.

A small amount of debugging shows that the problem begins with the first call to legend which creates two legend objects instead of just one.

Rik <rik5>
Project Administrator
Tue 14 Apr 2015 08:15:11 AM UTC, original submission:  

I have an old script that used to work in octave 3.2 which I've simplified as far as possible:

figure(1);
clf
N = 10;
[ax,h1,h2] = plotyy( 1:N, rand(1,N), 1:N, rand(1,N), @plot, @plot );

axes(ax(1)) % Should not be needed
legend( ax(1), 'values1', 'Location', 'northwest');

axes(ax(2))
legend( ax(2), 'values2', 'Location', 'northeast');

set(ax(1), 'color', 'none')
set(ax(2), 'color', 'none')

Tested today with 3.2.4 and it works.

This no longer works in version 3.6.2 or 3.8.1 or the latest dev sources.
The version I built this morning says 4.0.0-rc3

I only get one legend and not two as I expect.

Did most testing in 3.8.1 and changing to gnuplot for toolkit instead of fltk had no effect.

It does work in matlab 2014b.

As a workaround, I tried to create two axes myself instead of using plotyy and do the same thing.
The second code snippet works in 3.6 and 3.8 as well as matlab. Have not tested in 3.2.

Code:

figure(2);
clf
N = 10;
h1 = plot(1:N, rand(1,N), 'r');

a1 = gca();
a2 = axes();

h2 = plot(a2, 1:N, rand(1,N),'g');

% I know I haven't positioned a2 to the right as the first example will do automatically

legend(a1, 'first', 'Location', 'northwest');
legend(a2, 'second', 'Location', 'northeast')

set(a1, 'color', 'none')
set(a2, 'color', 'none')

Mattias Linde <linde>

 

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

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by pantxo (Posted a comment)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by linde (Submitted the item)
  •  

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

    Only project members can vote.

     

     

     

    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2017-12-22 rik5 Priority5 - Normal => 3 - Low
        SummaryMultiple legends not working anymore with plotyy => Separate legends for each plotyy axis not possible
    2015-04-16 rik5 StatusNone => Confirmed
        Release3.8.1 => dev

    Back to the top


    Powered by Savane 3.5