bugGNU Octave - Bugs: bug #60588, Vector/scalar combination in...

 
 

bug #60588: Vector/scalar combination in plotting not well documented

Submitter:  Michael Leitner <mleitner>
Submitted:  Wed 12 May 2021 06:25:01 AM UTC
   
 
Category:  Documentation Severity:  3 - Normal
Priority:  3 - Low Item Group:  Documentation
Status:  Need Info Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * dev Operating System:  * Any
Fixed Release:  9.1.0 (current stable) Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Tue 30 Jan 2024 02:51:27 PM UTC, comment #3: 

I just tested with Matlab and they now consistently set the "marker" to "none" when there is one point.

This original test code,


plot (0.5, 0.5)


now produces a blank plot as does


x=(1:10)';
y=1;
plot(x,y)


which is 10 individual line objects each with one point.

I don't think we need to have perfect Matlab compatibility here.  They made a consistent choice, but also a confusing choice.  After calling plot() one expects to see something.  If there is nothing then I'm sure we will start to get bug reports about the plot() command not working.  Also, if the programmer intends to be using single point line objects they are sophisticated enough to know how to turn off the marker, or change it, if they want.

Closing bug as fixed since the documentation change has happened.

Rik <rik5>
Group administrator
Tue 30 Jan 2024 02:42:25 AM UTC, comment #2: 

as this is listed as a doc issue, I pushed a change to the plot docstring that describes the current behavior of a scalar+vector combination as a series of points.

https://hg.savannah.gnu.org/hgweb/octave/rev/8b17f4ebc13f

if that's all that's required we can probably close the report. But as rik pointed out, and I just verified with v 2023b, matlab produces the same output but with marker set to 'none'.

is that something we care to emulate?

Nicholas Jankowski <nrjank>
Group Member
Wed 12 May 2021 03:38:52 PM UTC, comment #1: 

I think this can be documented more clearly, but the behavior should probably stay Matlab-compatible.

For the sample code, Matlab produces 10 line objects.  The "LineStyle" property is '-' and the "Marker" property is 'none'.

Octave does nearly the same thing.  It creates 10 line objects with "LineStyle" = '-'.  However, the "Marker" property is '.' which thus at least displays the points.

Interestingly, I'm pretty sure this is a change in behavior for Matlab.  I remember that Octave had to introduce a special case for one point like this


plot (0.5, 0.5)


so that the "Marker" property would be '.' rather than the default of "none".  That it still the case.  This code


h = plot ([0 1], [0 1])
get (h, 'marker')


is not special-cased because it has more than one point and the "Marker" is "none".

Rik <rik5>
Group administrator
Wed 12 May 2021 06:25:01 AM UTC, original submission:  

Plotting


x=(1:10)';
y=1;
plot(x,y)


gives ten points of different colour. I would have expected the y to be singleton-expanded and thus a single line to be plotted. The point is that if x is a very large vector, the execution takes unexpectedly long, while a single line would have been drawn much quicker. I see that the Matlab documentation says that in the present case discrete points are plotted, but they say nothing about whether they should have the same style or not (which probably would also complete faster than the present case). As I see it, the octave documentation does not treat the present case at all.

So this is at least a documentation bug. Perhaps it is also a Matlab incompatibility, if Matlab should have the same style on all points. What I do not get is their point that to see the points a marker symbol has to be specified -- if no symbol is specified, does the plot stay empty? Because in fact that is what happens if in octave I execute plot(x,y,'-'), presumably because it plots ten lines consisting only of a single point. Thus, for the simplest conceivable plot you can request, just a single horizontal line, you have to do something like


plot([0 1],[1 1])


while the more obvious and simple


plot([0 1],1)


does not work, not even with an '-'. That's why I would argue here even for a voluntary Matlab incompatibility.

Michael Leitner <mleitner>

 

(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 (Posted a comment)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by mleitner (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 7 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2024-01-30 rik5 Open/ClosedOpen Closed
        Fixed ReleaseNone 9.1.0 (current stable)
    2024-01-30 nrjank StatusNone Need Info
    2021-05-12 rik5 CategoryPlotting Documentation
        Priority5 - Normal 3 - Low
        Release6.1.0 dev
        SummaryVector/scalar combination in plotting Vector/scalar combination in plotting not well documented

    Back to the top

    Powered by Savane 3.13-c373.
    Corresponding source code