How can I make them the same color even when overlapping?
I want to use transparent to some degree.
Plot[{1 + x, 2 - x}, {x, 0, 1},
PlotStyle ->
Directive[Red, Thickness[0.03], Opacity[0.3], CapForm["Round"]]]
How can I make them the same color even when overlapping?
One possibility?
p1 = Plot[1 + x, {x, 0, 1}, PlotStyle ->
Directive[Red, Thickness[0.03], Opacity[0.3], CapForm["Round"]]];
p2 = Plot[2 - x, {x, 0, 1}, PlotStyle ->
Directive[Red, Thickness[0.03], Opacity[0.3], CapForm["Round"]]];
ImageCompose[Rasterize[p1],
ColorReplace[Rasterize[p2], White -> Transparent]]
You can use a simplified function to mimic alpha blending:
alphaBlend[rgb_RGBColor, alpha_, back_ : White] := Blend[{rgb, back}, 1 - alpha]
Plot[{1 + x, 2 - x}, {x, 0, 1},
PlotStyle ->
Directive[alphaBlend[Red, 0.3], Thickness[0.03],
CapForm["Round"]]]
You can also account for the background color
Plot[{1 + x, 2 - x}, {x, 0, 1},
PlotStyle ->
Directive[alphaBlend[Red, 0.3, LightBlue], Thickness[0.03],
CapForm["Round"]], Background -> LightBlue]
(On preview this is basically what @kglr is saying)
PlotStyle -> Directive[Blend[{Red, White}, .7], Thickness[0.03], CapForm["Round"]]
? $\endgroup$