I have to plot different families of data some of which might be empty. If the data happens to be empty I want to automatically preserve the ordering of the PlotStyle's. For ListPlot this is easy to do. It takes for example the following input

ListPlot[{{Missing[]}, {{1, 3}, {2, 4}}}]

and correctly applies the second style to the second list of points while plotting nothing for the Missing data.

However, for ListPointPlot3D I cannot figure out the equivalent. (Note I do not want to replace missing entries with e.g. Nothing[] or remove them, because then the data sets will not be ordered correctly with the styles provided in PlotStyle.)

For example the following returns an error that the dataset is invalid:

ListPointPlot3D[{Missing[], {{1, 3, 3}, {2, 4, 4}}}]

How can I easily deal with plotting list which might be empty/Missing?


1 Answer 1


Oops, that was easy, just enter an empty list instead of Missing[]:

ListPointPlot3D[{{}, {{1, 3, 3}, {2, 4, 4}}}]
  • $\begingroup$ Since he probably doesn't want to do manual replacement, I suggest including an automatic way, for example: data = {Missing[], {{1, 3, 3}, {2, 4, 4}}}; ListPointPlot3D[data /. Missing[] -> Nothing] $\endgroup$
    – Domen
    Apr 21, 2023 at 13:33
  • $\begingroup$ Haha, actually I am the OP, I stumbled on the solution just after posting. Note that your suggestion is not what I want. It is important to preserve something so that the ordering of the styles remains correct. Therefore the automatic replacement version would be: data = {Missing[], {{1, 3, 3}, {2, 4, 4}}}; ListPointPlot3D[ data /. Missing[] -> {}]. $\endgroup$
    – Kvothe
    Apr 21, 2023 at 14:04
  • $\begingroup$ Oh, sorry, I wasn't paying attention :) $\endgroup$
    – Domen
    Apr 21, 2023 at 15:01

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.