TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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!

share|improve this question
Have a look at texample.net for inspirations. – Hendrik Vogt Dec 6 '10 at 18:13
up vote 28 down vote accepted

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);


share|improve this answer
+1.5 for not using the built-in sin curve. – Loop Space Dec 6 '10 at 19:31

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.