我想画下面的图但我不知道该怎么画。
这是我的代码,尽管它没有运行:
\begin{tikzpicture}[>=stealth,scale=10]
\draw[color=gray!30,very thin](-0.1,-0.004)
grid[ystep=0.01,xstep=0.1](1.02,0.042);
\draw[->](-0.1,0)--(1.02,0);
\draw[->](0,-0.004)--(0,0.042);
\draw[thick,blue,domain=0:1.02,samples=200] plot(\x,{(\x)/(70*(2-\x*\x))}) node[below] {$y=\frac{q}{70(2-q^2)}$};;
\draw[thick,red,domain=0:1,samples=200] plot(\x,{(1+sqrt(1-\x*\x))/(70)}) node[above] {$y=\frac{1}{70}(1+\sqrt{1-q^2})$};;
\end{tikzpicture}
有人知道我该如何改变我的代码来绘制这个吗?
答案1
编辑: 抱歉,在第一个版本的答案中,我重写了您的方程式,但出现了错误。现在已更正。
以下是绘制图表的两个版本:
- 与传说
- 标签位于曲线上方/下方
\documentclass[margin=3mm, preview]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\begin{document}
\begin{tikzpicture}
\begin{axis}[height=44mm, width=88mm,
grid=both,
minor tick num=4,
minor grid style = {very thin},
ymax = 0.03,
xlabel = $x$, ylabel = $y$,
scaled y ticks=false,
yticklabel style={/pgf/number format/.cd, fixed, precision=2},
tick label style = {font=\footnotesize},
enlarge x limits = false,
domain = 0:1, samples = 201, no marks,
every axis plot post/.append style={very thick},
legend style={cells={anchor=west, yshift=3mm},
font=\scriptsize,
legend pos = outer north east}
]
\addplot {x/(70*(2-x^2))};
\addplot {(1+sqrt(1-x^2))/70};
\legend{$\frac{x}{70(2-x^2)}$, $\frac{1}{70(1+\sqrt{1-x^2})}$}
\end{axis}
\end{tikzpicture}
\bigskip
\begin{tikzpicture}[
N/.style = {font= \footnotesize, text=black, pos=0.6}
]
\begin{axis}[height=44mm, width=88mm,
grid=both,
minor tick num=4,
minor grid style = {very thin},
ymax = 0.03,
xlabel = $x$, ylabel = $y$,
scaled y ticks=false,
yticklabel style={/pgf/number format/.cd, fixed, precision=2},
tick label style = {font=\footnotesize},
enlarge x limits = false,
domain = 0:1, samples = 201, no marks,
every axis plot post/.append style={very thick},
]
\addplot {x/(70*(2-x^2))} node[N, above] {$\frac{x}{70(2-x^2)}$};
\addplot {(1+sqrt(1-x^2))/70} node[N, below] {$\frac{1}{70(1+\sqrt{1-x^2})}$};
\end{axis}
\end{tikzpicture}
\end{document}