Skip to content

Commit

Permalink
plot3: Draw marker when only a single point is plotted.
Browse files Browse the repository at this point in the history
Although this is not Matlab-compatible, it is very confusing to
issue a plot command and have nothing drawn.  Octave had already
made the choice for the 2-D plot command to draw a marker for
a single point so now the 2-D and 3-D cases behave the same.

* NEWS.10.md: Announce change in Graphics Backend section.

* plot3.m: Check input data for being a single point and set 'marker' to '.'
and 'linestyle' to '-'.
  • Loading branch information
Rik committed Oct 15, 2024
1 parent 8edac10 commit 510c381
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
5 changes: 4 additions & 1 deletion etc/NEWS.10.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ Summary of important user-visible changes for version 10 (yyyy-mm-dd):
`'rtick'` by the function `rticks` will only include the center tick mark
value if it is specified.

- `view` correctly interprets cartesian viewpoints on main axes (bug #65641).
- `view` correctly interprets Cartesian viewpoints on main axes (bug #65641).

- `plot3` now draws a single marker if only one data point is given.
Previously the plot was blank (`marker` = "none") which was confusing.

### Matlab compatibility

Expand Down
24 changes: 21 additions & 3 deletions scripts/plot/draw/plot3.m
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,13 @@
linestyle = options.linestyle;
marker = options.marker;
if (isempty (marker) && isempty (linestyle))
[linestyle, marker] = __next_line_style__ ();
if (isscalar (x))
## If unspecified, marker for a point is always "."
linestyle = "-";
marker = ".";
else
[linestyle, marker] = __next_line_style__ ();
endif
endif
color = options.color;
if (isempty (color))
Expand Down Expand Up @@ -268,7 +274,13 @@
linestyle = options.linestyle;
marker = options.marker;
if (isempty (marker) && isempty (linestyle))
[linestyle, marker] = __next_line_style__ ();
if (isscalar (x))
## If unspecified, marker for a point is always "."
linestyle = "-";
marker = ".";
else
[linestyle, marker] = __next_line_style__ ();
endif
endif
color = options.color;
if (isempty (color))
Expand Down Expand Up @@ -344,7 +356,13 @@
linestyle = options.linestyle;
marker = options.marker;
if (isempty (marker) && isempty (linestyle))
[linestyle, marker] = __next_line_style__ ();
if (isscalar (x))
## If unspecified, marker for a point is always "."
linestyle = "-";
marker = ".";
else
[linestyle, marker] = __next_line_style__ ();
endif
endif
color = options.color;
if (isempty (color))
Expand Down

0 comments on commit 510c381

Please sign in to comment.