我正在尝试用乳胶绘制该图形,但找不到添加 B 点和 y = x^2 和 y = x 标签的方法:
我这样做了:
使用此代码:
\documentclass[]{book}
\usepackage{systeme, microtype, amsmath, pgfplots, geometry}
\usetikzlibrary{datavisualization}
\usetikzlibrary{datavisualization.formats.functions}
\let\ds\displaystyle
\begin{document}
\tikz[scale=0.75,domain=-0.1:1.1,samples=50]{
\begin{axis}[axis x line=middle, axis y line=middle, stack plots=y]
\addplot+[mark=none] {x};
\addplot+[mark=none, fill=green, fill opacity=0.25] {min(x^2 - (x), 0)} \closedcycle;
\end{axis}
}
\end{document}
谁能帮我?
答案1
我还发现 x 轴和 y 轴标签的默认位置有点不合适,所以我或多或少手动放置了它们。通过调整锚点,您将能够移动它们。并且我删除了所有不必要的包。
\documentclass[]{book}
\usepackage{pgfplots,geometry}
\pgfplotsset{compat=1.16}
\begin{document}
\tikz[scale=0.75,domain=-0.1:1.1,samples=50]{
\begin{axis}[axis x line=middle, axis y line=middle, stack plots=y]
\addplot+[mark=none] {x};
\addplot+[mark=none, fill=green, fill opacity=0.25] {min(x^2 - (x), 0)} \closedcycle;
\node[circle,fill,scale=0.3,label=right:$B$] at (axis cs:1,1){};
\node[anchor=south west] at (axis cs:0.75,0.5){$y=x^2$};
\node[anchor=south east] at (axis cs:0.5,0.5){$y=x$};
\end{axis}
\node[anchor=south east,scale=0.75] at (current axis.right of origin) {$x$};
\node[anchor=north west,scale=0.75] at (current axis.above origin) {$y$};
}
\end{document}