From 510c3817582f1febbda05b69297eae3b057c3763 Mon Sep 17 00:00:00 2001 From: Rik Date: Tue, 15 Oct 2024 12:02:15 -0700 Subject: [PATCH] plot3: Draw marker when only a single point is plotted. 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 '-'. --- etc/NEWS.10.md | 5 ++++- scripts/plot/draw/plot3.m | 24 +++++++++++++++++++++--- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/etc/NEWS.10.md b/etc/NEWS.10.md index 45ac00e4ad..627f2848a8 100644 --- a/etc/NEWS.10.md +++ b/etc/NEWS.10.md @@ -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 diff --git a/scripts/plot/draw/plot3.m b/scripts/plot/draw/plot3.m index d6f241e9ff..41bda7616f 100644 --- a/scripts/plot/draw/plot3.m +++ b/scripts/plot/draw/plot3.m @@ -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)) @@ -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)) @@ -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))