octave-bug-tracker
[Top][All Lists]
Advanced

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

[Octave-bug-tracker] [bug #57319] legend() fails after being repeadetly


From: anonymous
Subject: [Octave-bug-tracker] [bug #57319] legend() fails after being repeadetly called (show/off) after plotyy
Date: Thu, 28 Nov 2019 03:08:56 -0500 (EST)
User-agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:70.0) Gecko/20100101 Firefox/70.0

URL:
  <https://savannah.gnu.org/bugs/?57319>

                 Summary: legend() fails after being repeadetly called
(show/off) after plotyy
                 Project: GNU Octave
            Submitted by: None
            Submitted on: Thu 28 Nov 2019 08:08:54 AM UTC
                Category: Plotting
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: Unexpected Error
                  Status: None
             Assigned to: None
         Originator Name: 
        Originator Email: address@hidden
             Open/Closed: Open
         Discussion Lock: Any
                 Release: dev
        Operating System: GNU/Linux

    _______________________________________________________

Details:

I've got a plot created with plotyy(), and when I run the following code, I
get an unexpected error: 

plotyy(rand(1,4),rand(1,4),rand(1,8),rand(1,8))
legend show
legend off %everything's fine up to this point
legend show


The error is the following one: 

error: getappdata: H must be a scalar or vector of graphic handles
error: called from
    getappdata at line 42 column 5
    legend>parse_opts at line 707 column 17
    legend at line 127 column 8


There's a point in legend.m for catching every legend handle associated with
the axes:

## Find any existing legend object associated with axes
  try
    legend_handle = get (axes_handles, "__legend_handle__");
    if (iscell (legend_handle)) 
...

It looks like _legend off_ doesn't clear the legend handle of the secondary
y-axis for some reason. Thus, when I call _legend show_ again afterwards, the
variable legend_handle doesn't return an empty double (as it should) but
instead a cell that contains the empty double and an invalid legend handle
associated with the secondary y-axis.  
Subsequently, about 80 lines down the code, the statement 

elseif (nargs > 0 || isempty (legend_handle))

is false but should be true in the case of _legend show_ when there is
currently no active legend. In the else-case

obj_handles = getappdata (legend_handle, "__peer_objects__");

in _getappdata_ the error occurs because the 'legend_handle' is not a valid
handle (ishghandle() is false). 

The underlying cause is that _legend off_ doesn't clear all legend handles.
Personally I found a workaround by checking if either legend_handle cell is
empty and setting legend_handle empty if that's true.  

(I've got the latest legend.m function as of 26th Nov. if that helps)




    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?57319>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

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