How to draw area below a function at certain interval?

Hi all,

how do we draw an area like below (definite integral)?
index

and how to make the result function of the area becomes in the same box like label?

This is my code:

using Plots, LaTeXStrings
gr()

function Area(f, a, b, n)
xs = a:(b-a)/n:b
deltas = diff(xs)
cs = xs[1:end-1]
sum(f(cs[i]) * deltas[i] for i in 1:length(deltas))
end

f(x) = x^2
Area(x -> x^2, 0, 1, 50_000)

plot(f,0,1, label=L"y = x^2", legend=:outertop)
annotate!([(0.77,0.95, ("Area = ", 11, :black)),
	  (0.77,0.85, (Area(x -> x^2, 0, 1, 50_000), 11, :black))])

Have a look at the fill keyword argument: Overview · Plots

For example:

plot(f,0,1, legend=false)
plot!(f,0.5,0.75, fill=(0, 0.25, :blue))

image

Thanks for your help