I'm trying to draw 3D plot from my experimental points in the way shown at the figure below:
I tried to use ListPointPlot3D for that, but obviously there is no option Joined as in ListPlot.
mydata = Table[{x, y, x*y*y}, {x, 0, 1, 0.03}, {y, 0, 10, 1}];
ListPointPlot3D[mydata, Filling -> Bottom,
ColorFunction -> Function[{x, y, z}, RGBColor[y, 0., 0.3]]]
So I obtained this:
Any idea how I can join the point to obtain the set of flat curves with filling?
Answer
I don't see an easy way to do this with ListPointPlot3D or by layering a bunch of 2D ListPlots in a 3D box. However, it's fairly straightforward to do this manually, with basic graphics primitives. The shape of each curve is simply a polygon that traverses all the points in each row, but also includes one point at at z = 0 below the first and last point in the list. You'll just have to take care of colouring yourself:
color[n_] := With[{palette = ColorData[97, "ColorList"]},
palette[[Mod[n, Length@palette, 1]]]
]
Graphics3D[
MapIndexed[
{
Opacity@0.5,
color@#2[[1]],
Polygon[Join[#, {Last@#*{1, 1, 0}, First@#*{1, 1, 0}}]]
} &,
mydata
],
BoxRatios -> {1, 1, 1/2},
Axes -> True,
Lighting -> "Neutral"
]
Note that this fills in the y-z planes. If you want to fill in the x-z planes instead, simply use Transpose @ mydata inside the MapIndexed instead:




Comments
Post a Comment