I would like to plot the shaded region between $y=\sin(x)$ and $y=0$ over $x \in [0, \pi]$ using TikZ and/or possible other packages which I don't know yet. Can you give some examples?


how to do the computation of the special function $\sin$?

how to specify the region in TikZ?

how to shade the region?

Thanks and regards!


1 Answer 1


This is explained in the sections “15.4 Filling a Path” and “19 Plots of Functions” in the TikZ manual (numbers refer to the 2.10 version).

A simple example (note that \x r interprets \x as radians; the TikZ's sin function takes degrees as input):


    \fill[fill=red] (pi/4,0) -- plot [domain=pi/4:3*pi/4] (\x,{sin(\x r)}) -- (3*pi/4,0) -- cycle;
    \draw plot[domain=0:pi] (\x,{sin(\x r)});

    \draw[gray,->] (-0.3,0) -- (pi+0.3,0);



You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .