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

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

[Octave-bug-tracker] [bug #48647] Matlab incompatible plot output - line


From: Nicholas Jankowski
Subject: [Octave-bug-tracker] [bug #48647] Matlab incompatible plot output - linewidth on multiple curves handled differently
Date: Wed, 27 Jul 2016 17:37:55 +0000 (UTC)
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:47.0) Gecko/20100101 Firefox/47.0

URL:
  <http://savannah.gnu.org/bugs/?48647>

                 Summary: Matlab incompatible plot output - linewidth on
multiple curves handled differently
                 Project: GNU Octave
            Submitted by: nrjank
            Submitted on: Wed 27 Jul 2016 05:37:53 PM GMT
                Category: Plotting
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: Matlab Compatibility
                  Status: None
             Assigned to: None
         Originator Name: Nicholas Jankowski
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any
                 Release: 4.0.3
        Operating System: Microsoft Windows

    _______________________________________________________

Details:

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




    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?48647>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

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