Kind of as an extension of this question: How to plot a series using different colors depending on the y-value
Is there something similar to MeshFunction
or ColorFunction
that can control whether a curve being plotted is dashed vs solid depending on the y-value?
Answer
A simple modification of the answer in the linked Q/A:
data = RandomReal[{0, 3}, 100];
ListLinePlot[data, MeshFunctions -> {#2 &}, Mesh -> {{1, 2}},
MeshShading -> {Blue, Directive[Red, Dashed], Green}, MeshStyle -> None]
Use MeshShading -> {Dashing[.02], Dashing[None], Dotted}
to get
Comments
Post a Comment