Hi all,
I want to ask whether I am right that the triangle region between 0 and \pi/2 should not be included for region bounded by \sin (x) and \cos (x) between x = - \pi / 4 and x = 3 \pi / 4 ?
But, In the plot below it becomes dark blue since it is filled twice. How to make it all correctly filled so none is darker than the other?
using Plots, LaTeXStrings, Plots.PlotMeasures, CalculusWithJulia
gr()
function pitick(start, stop, denom; mode=:text)
a = Int(cld(start, π/denom))
b = Int(fld(stop, π/denom))
tick = range(a*π/denom, b*π/denom; step=π/denom)
ticklabel = piticklabel.((a:b) .// denom, Val(mode))
tick, ticklabel
end
function piticklabel(x::Rational, ::Val{:text})
iszero(x) && return "0"
S = x < 0 ? "-" : ""
n, d = abs(numerator(x)), denominator(x)
N = n == 1 ? "" : repr(n)
d == 1 && return S * N * "π"
S * N * "π/" * repr(d)
end
function piticklabel(x::Rational, ::Val{:latex})
iszero(x) && return L"0"
S = x < 0 ? "-" : ""
n, d = abs(numerator(x)), denominator(x)
N = n == 1 ? "" : repr(n)
d == 1 && return L"%$S%$N\pi"
L"%$S\frac{%$N\pi}{%$d}"
end
a, b = -2π, 2π
y(x) = sin(x)
y2(x) = cos(x)
xs1 = range(a, b, length=150)
plot(xs1, y, color=:red, xtick=pitick(a, b, 4; mode=:latex),
xlims=(-3,3), ylims=(-π/2,π/2),framestyle=:zerolines,
linestyle=:solid, linecolor=:red2,
legend=:topleft, label=L"y = \sin \ x",
bottom_margin=3mm,
size=(800, 460), tickfontsize=10)
plot!(xs1,y2, label=L"y = \cos \ x")
plot!(y,-π/4,3π/4, label="", fill=(0, 0.15, :blue))
plot!(y2,-π/4,3π/4, label="", fill=(0, 0.15, :blue))
I tried PolygonArea
and use plot!(y2 \ y, color=:green)
→ not working