Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I want to do some plots using TikZ, however the following code doesn't work:


      \draw[->] (-3,0) -- (2.2,0) node[right] {$x$}; %
      \draw[->] (0,-0.5) -- (0,3.2) node[above] {$y$};%
      \draw plot (\x,{\x^2});%

Any idea what's wrong?

How to plot functions like x \mapsto a^x (a > 0)?

Edit: Thanks for the patch, however ploting 2^x doesn't work, I get the following picture using Jakes answer:

enter image description here

share|improve this question
Could you please change the image to not include a large white space on top? Also please describe your issue more precise. "Doesn't work" is not very descriptive. –  Martin Scharrer May 19 '11 at 19:11
possible duplicate of How can I work around this TikZ bug? –  Jake May 19 '11 at 19:19
Could you add the code you used to generate the image? –  Jake May 19 '11 at 19:47
@Jake: I copied exactly your code from below. –  student May 19 '11 at 20:23

1 Answer 1

As Martin Scharrer pointed out, this is a bug that Hendrik Vogt has provided a patch for in his answer to the question How can I work around this TikZ bug?

On a side note: tikz loads pgf automatically, so you don't need to load it explicitly.




      \draw[->] (-2.2,0) -- (2.2,0) node[right] {$x$}; %
      \draw[->] (0,-0.5) -- (0,3.2) node[above] {$y$};%
      \draw [domain=-2:2,orange] plot (\x,\x^2);
      \draw [domain=-2:2,blue] plot (\x,2^\x);%

tikz plot

share|improve this answer
Is this that PGF bug for v2.1 (or was it v2.x)? –  Martin Scharrer May 19 '11 at 19:10
@Martin: Indeed, you're right. Thanks for pointing that out. So this should be closed as a duplicate? –  Jake May 19 '11 at 19:18
Thanks, however plotting 2^\x seems not to work –  student May 19 '11 at 19:29
@user4011: It does for me, see the edited answer. Maybe you'se using an old version of TikZ? –  Jake May 19 '11 at 19:37
@Jake: How to find out the tikz version? See my edit above –  student May 19 '11 at 19:46

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.