1
$\begingroup$

For some reason, showing gaps in data is easier with ListLinePlot than with the closely related ListLinePlot3D. For example, Null can be used to show gaps in data as below in the orange plot.

ListLinePlot[{{1, 2, 3, 2, 4, 4, 3, 4}, {4, 1, 0, 1, Null, Null, 1, 2}},
 Mesh -> Full, AxesLabel -> {"x", "y"}]

ListLinePlot1

However, this does not work correctly with ListLinePlot3D, whereby Null is interpreted as interpolation between the elements it lies between, as illustrated below.

ListLinePlot3D[{{1, 2, 3, 2, 4, 4, 3, 4}, {4, 1, 0, 1, Null, Null, 1, 2}}, 
Mesh -> Full, AxesLabel -> {"x", "y"}]

ListLinePlot3D1

Replacing Null with Nothing or Sequence[] doesn't work for the obvious reasons, and using Indeterminate, using Missing[], and using some non-numeric element like an empty string all give the same result Null gives.*

How can I accurately represent gaps in data the way ListLinePlot does but with ListLinePlot3D? The data sets I am dealing with are quite large with many "gaps", so I'd like the solution to scale well and have good performance.


*In the case of Missing[], it seems like this is an oversight, as the following are stated and demonstrated in the documentation for ListLinePlot: "Plotting functions automatically omit Missing objects when plotting data" and "Visualization typically automatically filters out Missing elements". I consider ListLinePlot3D a "plotting function" and "visualization", but it does not have the behavior specified.

$\endgroup$

1 Answer 1

1
$\begingroup$
data = {{1, 2, 3, 2, 4, 4, 3, 4}, {4, 1, 0, 1, Null, Null, 1, 2}};

Graphics3D[{Thick, 
  MapIndexed[({d, i} |-> {ColorData[97][First[i]], 
      Line@SequenceSplit[
        MapIndexed[{First[#2], First[i], #1} &, d], {{_, _, Null}}]}),
    data]}, Axes -> True, BoxRatios -> {1, 1, 0.4`}]

ListLinePlot3D[data, Mesh -> Full]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.