![如何绘制此图](https://linux22.com/image/329698/%E5%A6%82%E4%BD%95%E7%BB%98%E5%88%B6%E6%AD%A4%E5%9B%BE.png)
这是我第一次使用 latex。我正在尝试绘制这个图形。这是我的代码
\documentclass{article}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
xmin=-5,xmax=5,
axis y line*=left,
\addplot {x^2};
\end{axis}
\begin{axis}[
xmin=0,xmax=15,
domain=0:15,
\addplot[red] {x};
\end{axis}
\end{tikzpicture}
\end{document}
答案1
您只是忘记关闭轴选项了]
:
\documentclass{article}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
xmin=-5,xmax=5,
axis y line*=left,
]% <--- added
\addplot {x^2};
\end{axis}
\begin{axis}[
xmin=0,xmax=15,
domain=0:15,
]% <--- added
\addplot[red] {x};
\end{axis}
\end{tikzpicture}
\end{document}