我想绘制 x^1/2-x 和隐函数 (y^0.2-y)/2=x 的图形,但第二个函数有问题。我不确定如何使用 tikz 绘制该函数,我的尝试(如下)似乎不起作用。
> \usepackage{pgfplots}
> \begin{document}
> \tikzset{declare function={f(\x)=(\x)^(1/2)-\x;}}
> \begin{tikzpicture}[scale=0.85]
> \begin{axis}[domain=0:0.5,ytick={1},xtick={1,2,3,4},
> xmin=0,ymin=0,ymax=0.5,xmax=0.5,mark=none,samples=100]
> \addplot[black] {f(x)};
> \draw[variable=\y,red] plot ({(\y^0.2-\y)/2},{\y});
> \end{axis}
> \draw [black, dashed] plot coordinates {(-.1,2.85) (3.4,2.85)};
> \draw [black, dashed] plot coordinates {(3.43,-.1) (3.43,2.8)};
>
> \node at (3.43,-.3) {\small $1$};
> \node at (6.5,-.3) {\small $b_1$};
> \node at (-.23,2.85) {\small $1$};
> \node at (-.23,5.4) {\small $b_2$};
> \node at (5.8,3) {\small $b_2=r_2(b_1)$};
> \node [text=red] at (4,5.4) {\small $b_1=r_1(b_2)$};
> \end{document}
答案1
只需将这些选项传递给适当的内容\addplot
,或添加plot
。
\documentclass[tikz,border=3.14mm]{standalone}
\usepackage{pgfplots}
\begin{document}
\tikzset{declare function={f(\x)=(\x)^(1/2)-\x;
g(\x)=(pow(\x,0.2)-\x)/2;}}
\begin{tikzpicture}[scale=0.85]
\begin{axis}[domain=0:0.5,ytick={1},xtick={1,2,3,4},
xmin=0,ymin=0,ymax=0.5,xmax=0.5,mark=none,samples=100]
\addplot[black] {f(x)};
\addplot[domain=0:1,red] ({g(x)},{x});
\end{axis}
\draw [black, dashed] plot coordinates {(-.1,2.85) (3.4,2.85)};
\draw [black, dashed] plot coordinates {(3.43,-.1) (3.43,2.8)};
\begin{scope}[font=\small]
\node at (3.43,-.3) {$1$};
\node at (6.5,-.3) {$b_1$};
\node at (-.23,2.85) {$1$};
\node at (-.23,5.4) {$b_2$};
\node at (5.8,3) {$b_2=r_2(b_1)$};
\node [text=red] at (4,5.4) {$b_1=r_1(b_2)$};
\end{scope}
\end{tikzpicture}
\end{document}