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 have the following code.

\begin{axis}[domain = -2:2
         ,y domain = -2:2,view={0}{90}] 

\addplot3[contour gnuplot={number=10},thick,domain=-2:2]

But I'd like it to plot just the area inside a circle x^2+y^2 < 1 Any Idea?

share|improve this question
Why not a simple circle filled? – percusse Feb 10 '13 at 2:19
@percuße I want it to be filled by the mentioned contour. How? – batista cori Feb 10 '13 at 2:21
Do you mean clipping with a circle or a circle under these countours? – percusse Feb 10 '13 at 2:23
@percuße clipping with a circle. – batista cori Feb 10 '13 at 2:24
up vote 4 down vote accepted

I can't see where that extra 3.5 scaling factor comes from but this should be robust to scaling and other shifts etc.

Edit : the clipping path can be much simplified thanks to Christian's correction.

\begin{axis}[domain = -2:2,y domain = -2:2,view={0}{90},grid=both] 
\clip (axis cs:0,0) circle (1 and 1); 
\addplot3[contour gnuplot={number=10},thick,domain=-2:2]{0.5*exp(-0.2*abs(x)-0.2*abs(y))}; 

enter image description here

share|improve this answer
worked! Thanks. – batista cori Feb 10 '13 at 2:59
If you omit units after the circle path, the radii will be interpreted as (pgfplots!) axis units: \clip ... circle (1 and 1); . Note furthermore that \pgfplotsextra is the correct choice, but is is inserted automatically if you omit it. – Christian Feuersänger Feb 10 '13 at 16:15
@ChristianFeuersänger Much better and obvious. I didn't know that. Thank you. By the way can you see why the need to scale with 3.5? – percusse Feb 10 '13 at 16:19
This is a consequence of the internal data scalings. Consequently, the 3.5 would have been wrong if the limits where from, say, -200 .. 200. – Christian Feuersänger Feb 10 '13 at 21:07

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.