0

I do not know that my problem is but the axis of my graphs do not go through the origin. I've read this answer but it does not work for me.

Here is a MWE:

\documentclass{article}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[ axis lines=middle]
\addplot {x^2+20};
\end{axis}
\end{tikzpicture}
\end{document}

and my output enter image description here

Maybe you can tell me what is wrong.

garondal
  • 455
  • Right, it goes through (0,20) as you specified in \addplot {x^2+20};. So is you question how to change the range of the y-axis? – MS-SPO Mar 12 '24 at 08:56
  • No, I want that the x- and y-axis pass though (0,0) and draw the plot of y=x^2+20. Is this not possible? – garondal Mar 12 '24 at 08:57
  • y(0) = 0^2 + 20 = 20. No, it's not possible. Simple math ... // try instead \addplot{x^2}; ... – MS-SPO Mar 12 '24 at 09:00
  • You can specify ymin=0 in the axis option – NBur Mar 12 '24 at 09:01
  • I think you do not understand my questions. I know that the graph passes through (0,20) but I want that the x-axis passes through (0,0) and not (0,20). – garondal Mar 12 '24 at 09:01

1 Answers1

1

You can specify ymin=0 in the axis option

\documentclass{article}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[ axis lines=middle,ymin=0]
\addplot {x^2+20};
\end{axis}
\end{tikzpicture}
\end{document}

enter image description here

NBur
  • 4,326
  • 10
  • 27