3
$\begingroup$

I would like to plot a 1D graph with two curves that identically overlap. For example, trivially consider

Plot[Sin[x], {x, 0, 3}]

What are the best options to use to plot two overlapping $\sin$ cuves (in the same domain) such that the graphs are (to some extent) visually distinguishable so that the reader can say: "yes, these two plots are the same" -- for more interesting cases, though.

Thanks.

$\endgroup$
  • 4
    $\begingroup$ Why not plot the difference of the two functions? $\endgroup$ – march Aug 22 '16 at 1:10
6
$\begingroup$

For any curves that might overlap even just a little:

Plot[{Sin[x], Sin[x]}, {x, 0, 3}, 
 PlotStyle -> {{Thickness[0.03], LightGray}, Red},
 PlotLegends -> {"Curve 1", "Curve 2"}]

Two identical curves

$\endgroup$
2
$\begingroup$

Use a combination of Show with MeshStyle and/or PlotStyle

Show[
 Plot[Sin[x], {x, 0, Pi}, Mesh -> 20, 
  MeshStyle -> Directive[PointSize[0.02], Red], 
  PlotStyle -> Directive[Thickness[0.01], Red], MaxRecursion -> 0],
 Plot[Cos[x - Pi/2], {x, 0, Pi}, Mesh -> 20, 
  MeshStyle -> Directive[PointSize[0.01], Blue], 
  PlotStyle -> Directive[Thickness[0.0025], Blue], MaxRecursion -> 0]
 ]

enter image description here

$\endgroup$
  • $\begingroup$ 兄弟reputation涨得好猛 :) $\endgroup$ – yode Aug 22 '16 at 9:34
2
$\begingroup$

Using Epilog directly.

Plot[Sin[x], {x, 0, 3}, 
     PlotStyle -> {Blue, Opacity[0.5]}, 
     Epilog -> {Dashed, Red, Line[Table[{t, Sin[t]}, {t, 0, 3, 0.1}]]}]

enter image description here

$\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.