但是我的结果是这样的:
我遇到的问题:
- 曲线看上去不太平滑、均匀。
- 我尝试绘制(\draw)的任何内容都没有出现在图中,我正尝试在图中添加文本。
代码:
\begin{tikzpicture}
\begin{axis}[xlabel = {lowest to highest},
ylabel = {income earned},
xmin = 0,
xmax = 1,
ymin = 0,
ymax = 1
]
\addplot[smooth]{x};
\addplot[smooth, thick, label=$x$]{x^2};
\coordinate (P) at (0,0);
\node[rotate=45] (N) at (P) {lorenz curve};
\end{axis}
\end{tikzpicture}
尝试绘制文本节点的最后一部分只是我在这里找到的东西:TikZ 对角线文本。 我究竟做错了什么?
答案1
像这样吗?
\documentclass[tikz,border=3.14mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\begin{document}
\begin{tikzpicture}
\begin{axis}[xlabel = {lowest to highest},
ylabel = {income earned},
xmin = 0,
xmax = 1,
ymin = 0,
ymax = 1
]
\addplot[domain=0:1]{x} node[midway,above,sloped]{Line of equality}
node[midway,below,sloped]{Concentration area};
\addplot[domain=0:1,smooth, thick, label=$x$]{x^2}
node[midway,below,sloped]{Lorenz curve};
\end{axis}
\end{tikzpicture}
\end{document}