I am doing a plot where I have multiple shaded regions, and I want the line that separates the two regions to be dashed with dashes being alternating colors (so the demarcation stands out from both regions).
For example, say I am plotting the two regions shown here
Plot[{1, Abs[BesselJ[1, x]]}, {x, 0, 20}, Filling -> Axis]
The only way I could think to add the dashing was using ColorFunction
, but it doesn't give what I'm looking for:
bgplot = Plot[{1, Abs[BesselJ[1, x]]}, {x, 0, 20},
Filling -> Axis, PlotStyle -> {Automatic, None}];
dashplot = Plot[Abs[BesselJ[1, x]], {x, 0, 20},
PlotStyle -> Thickness[.01],
ColorFunction -> (If[EvenQ[Floor[#]], Black, White]&),
ColorFunctionScaling -> False, PlotPoints -> 500];
Show[bgplot, dashplot]
This is almost what I want, but the dashes are all the same length in the x-coordinate, whereas I'd prefer they be the same total length. Also, I have to have PlotPoints
set to an unreasonably high value to avoid any gray regions.
Any ideas how to do this better?