bugGNU Octave - Bugs: bug #48647, Matlab incompatible plot output -...

 
 

bug #48647: Matlab incompatible plot output - linewidth on multiple curves handled differently

Submitter:  Nicholas Jankowski <nrjank>
Submitted:  Wed 27 Jul 2016 05:37:53 PM UTC
   
 
Category:  Plotting Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Matlab Compatibility
Status:  None Assigned to:  None
Originator Name:  Nicholas Jankowski Open/Closed:  * Open
Release:  * 4.0.3 Operating System:  * Microsoft Windows
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Wed 27 Jul 2016 06:03:49 PM UTC, comment #1: 

I guess to use the right nomenclature, matlab refers to the syntax as:

plot (Xn, Yn, 'LineSpecn', ..., 'propertyn','valuen')

and 'property','value' apply to the entire plot, not individual lines.

Nicholas Jankowski <nrjank>
Group Member
Wed 27 Jul 2016 05:37:53 PM UTC, original submission:  

This likely applies to more than just 'linewidth', but the following script works in Octave but errors out on Matlab 2016a:


x = [1:10];
y = rand(3,10);

figure(1);
plot(x,y); %all thin lines
figure(2);
plot(x,y,'linewidth',3);
figure(3);
plot(x,y(1,:),x,y(2,:),x,y(3,:),'linewidth',3);
figure(4);
plot(x,y(1,:),'linewidth',3,x,y(2,:),'linewidth',1,x,y(3,:),'linewidth',6);


in Octave 4.03:
Figure 1 - all lines thin
Figure 2 - all lines width = 3
Figure 3 - only line 3 width = 3
Figure 4 - each line a different width

in Matlab 2016b:

Figure 1 - all lines thin
Figure 2 - all lines width = 3
Figure 3 - all lines width = 3
Figure 4 - usage error:


Error using plot
Data must be a single matrix Y or a list of pairs X,Y.



It seems that Matlab plot command only allows "x,y,s" triplets (s being color/line/tickmark options like 'r-o'), and other property pairs must occur at the end of the command. If you specify a color the error message points a little better to this problem:


>> plot(x,y(1,:),'r','linewidth',3,x,y(2,:),'linewidth',1,x,y(3,:),'linewidth',6);
Error using plot
Invalid first data argument


It sees 'linewidth' when it can tell there are other data objects coming, meaning it requires it to be the start of another xy pair or xys triplet. whereas Octave plots it without problem, as it seems to only apply property pairs to the previous data item. Hence the linewidth applies to all lines in Fig 2, but only the last line in Fig 3, and each one can be made different as in Fig 4.

So, the primary issue here is that Octave fails to produce matlab compatible plot output as in figure 3. secondary problem is that matlab errors on octave compatible code as in figure 4. Since the figure 4 code is required to get Octave to produce Matlab compatible output, this is a bit of a trouble. At the moment I have cumbersome if(exist(octave))-type codeblocks to handle this.

According to matlab news posts the desired method to set different linewidths is using the individual line object handles after creating the plot.

i.e.,  set( h, { 'LineWidth' } , {2 2 2 1}' ), where h is a 1x4 vector of handles...

Nicholas Jankowski <nrjank>
Group Member

 

(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 nrjank (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.

     

    No changes have been made to this item

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code