I'm practically new to the pgfplots package. I want to plot the quadratic equation 2x²-5x+2 on a set of axes (this is for an A-level text book). I have two questions:
Why does plotting
x²in the domain[-2.5,2,5]result in the negative part being rotated 180°? This code:\documentclass{minimal} \usepackage{tikz,pgfplots} \begin{document} \begin{center} \begin{tikzpicture} @Axes \draw (0.1,-0.2) node[left]{\textcolor{gray}{O}}; \draw[thick, color=gray,->] (-5,0) -- (5,0) node[right] {\textcolor{black}{$x$}}; \draw[thick, color=gray, ->] (0,-1) -- (0,7) node[above] {\textcolor{black}{$f(x)$}}; @Plot \draw [red, thick, domain=-2.5:2.5, samples=100] plot(\x, {\x^2}); \end{tikzpicture} \end{center} \end{document}Outputs:
- Why does changing the equation to
2x²-5x+2in the above equation; i.e. writingplot(\x, {2\x^2-5\x+2});not output my axes at all, but instead outputs these two pages?
Any help will be greatly appreciated.



... plot (\x, {(\x)^2});ie with extra (parentheses).-2^2is different from(-2)^2– egreg Dec 07 '15 at 21:40plot (\x, {2*(\x)^2-5*(\x)+2}). And you probably want to adjust the domain.