bugGNU Octave - Bugs: bug #62883, plot() function handles...

 
 

bug #62883: plot() function handles property/value pairs differently from Matlab

Submitter:  Muhali <muhali>
Submitted:  Wed 10 Aug 2022 09:06:56 AM UTC
   
 
Category:  Plotting Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Matlab Compatibility
Status:  Confirmed Assigned to:  None
Originator Name:  Open/Closed:  * Open
Release:  * dev Operating System:  * GNU/Linux
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Wed 10 Aug 2022 09:45:40 PM UTC, comment #1: 

This is not a problem with the "parent" property, but rather a general difference between how Octave and Matlab handle property/value pairs.  In Octave, prop/val pairs apply to the nearest XY data and you can have different prop/val pairs for different sets of XY data.  In Matlab, you can specify a LineSpec per XY data set, but ALL XY data share the prop/val pairs.

Example


x = linspace(-2*pi,2*pi);
y1 = sin(x);
y2 = cos(x);
plot (x,y1,x,y2, 'color', 'm')


The result is that the first line uses the default color from the ColorOrder property while the second line has the default overridden to magenta.

File:octave.png

In Octave, you can apply properties individually so this works


plot (x,y1, 'color', 'r', x,y2, 'color', 'm')


File:octave2.png

If you try this syntax with Matlab it will generate an error because it only allows one set of property/value pairs and it must occur after all XY data has been specified.






Rik <rik5>
Group administrator
Wed 10 Aug 2022 09:06:56 AM UTC, original submission:  

suppose you do


x = 1 : 10 ;
y = rand(2, 10) ;

clf ;

h1 = hggroup ;
plot(x, y(1,:), x, y(2,:), 'parent', h1) ;
length(allchild(h1))

h2 = hggroup ;
plot(x, y(1,:), 'parent', h2, x, y(2,:), 'parent', h2) ;
length(allchild(h2))


then you get for the first plot command one line object (instead of two for Matlab) and for the second two line objects (instead of an error in Matlab).

Muhali <muhali>

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #53557:  octave.png added by rik5 (32KiB - image/png)
file #53558:  octave2.png added by rik5 (28KiB - image/png)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by rik5 (Updated the item)
  • -email is unavailable- added by muhali (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2022-08-10 rik5 Attached File- Added octave.png, #53557
        Attached File- Added octave2.png, #53558
        Item GroupNone Matlab Compatibility
        StatusNone Confirmed
        Release7.1.0 dev
        Summary'parent' property not working as expected plot() function handles property/value pairs differently from Matlab

    Back to the top

    Powered by Savane 3.13-3230.
    Corresponding source code