How to ask Mathematica to fill in colors between curves in the given code?
ListPlot[
{Thread[{x, y}], Thread[{x, y^2}],
Thread[{x, y^3}], Thread[{x, y^4}]},
Filling -> {
1 -> {{2}, Opacity[0.3, Red]},
3 -> {{4}, Opacity[0.3, Blue]}
},
PlotStyle -> {Red, Red, Blue, Blue}, Joined -> True,
PlotRange -> {1, 3}
]
You can also construct a TemporalData
object from your x
and y
and use it with ListLinePlot
:
td = TemporalData[Table[y^i, {i, 4}], {x}];
llp = ListLinePlot[td,
PlotStyle -> {Red, Red, RGBColor[.45, .77, .92], RGBColor[.45, .77, .92]},
Filling -> {1 -> {2}, 3 -> {4}},
PlotRange -> {1, All}]
Alternatively, use Table[y^i, {i, 4}]
as input data and add the option DataRange -> MinMax[x]
:
llp = ListLinePlot[Table[y^i, {i, 4}],
DataRange -> MinMax[x],
PlotStyle -> {Red, Red, RGBColor[.45, .77, .92], RGBColor[.45, .77, .92]},
Filling -> {1 -> {2}, 3 -> {4}},
PlotRange -> {1, All}]
SeedRandom[1]
Normal[llp] /. p_Polygon :> Dynamic[texturedPoly[CurrentValue["Color"]][p]]
where
ClearAll[texturedPoly]
texturedPoly[color_: Red, thickness_: 10, n_: 200, sd_: 100, jitter_: 5][p_Polygon] :=
Module[{BSF = BSplineFunction[Join @@ (RandomSample[Partition[#, 20]] & @
SortBy[RandomPoint[BoundingRegion[p[[1]], "MinConvexPolygon"], n], First])]},
{Opacity[.8], Texture @
ImageEffect[Graphics[{CapForm["Round"], JoinForm["Round"],
color, AbsoluteThickness[thickness],
Line[BSF /@ Subdivide[sd]]}], {"Jitter", jitter}],
Polygon[p[[1]], VertexTextureCoordinates -> Automatic]}]