1
$\begingroup$

I have a array and I want to plot it in 3d space by ListPointPlot3D function.

list = {{1, 2, 3, 4, 5}, {2, 2, 2, 2, 2}};
ListPointPlot3D[list]

The result is as following enter image description here

But I want to the two points lines combined. enter image description here

If I plot in 2d space, it works well by ListPlot, but I don't know how to solve it in 3D space.

$\endgroup$
3
$\begingroup$

Add the x and y coordinates:

list = {{1, 2, 3, 4, 5}, {2, 2,    2, 2, 2}};
list2 = Thread[{1, Range @ Length @ #, #}] & /@ list;
ListPointPlot3D[list2, BaseStyle -> PointSize[Large]]

enter image description here

$\endgroup$
0
$\begingroup$

Same color:

ListPointPlot3D /@ List /@ list // Show

enter image description here

Using Iterator in the "GeneralUtilities`" package to advance through the colors:

Needs@"GeneralUtilities`";
cyclicListIterator[input_List] := 
 GeneralUtilities`NewIterator[cyclicListIterator,
  {i = 0, n = Length[input], list = input}, list[[Mod[++i, n, 1]]]]

colors = "DefaultPlotStyle" /. (Method /. 
       Charting`ResolvePlotTheme[Automatic, ListPointPlot3D]) // 
    cyclicListIterator;
ListPointPlot3D[{#}, PlotStyle -> Read[colors]] & /@ list // Show

enter image description here

Note: The Iterator[] for the colors needs to be reset after each use. One could use With[{colors = ...}, ListPointPlot3D...].

The same thing but with old-style MapThread:

colors = "DefaultPlotStyle" /. (Method /. 
     Charting`ResolvePlotTheme[Automatic, ListPointPlot3D]);
MapThread[
  ListPointPlot3D[{#}, PlotStyle -> #2] &,
  {list, PadRight[colors, Length@list, colors]}
  ] // Show
(* same figure as immediately above *)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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