将节点添加到最后一个坐标

将节点添加到最后一个坐标

我有一个对数对数图,想突出显示最后一个坐标。例如

\begin{tikzpicture}
\begin{loglogaxis}[]
\addplot+[] coordinates{(0,0) (2,20) (3,100) (4,4000)};
\end{loglogaxis}
\end{tikzpicture}

我想要一个节点仅有的最后一个坐标的值为 4000。该选项nodes near coords不是我想要的,因为它只显示所有坐标及其对数值。

答案1

要使用未转换的坐标值标记点,可以使用 提供这些值visualization depends on=rawy \as \pgfplotspointrawy。要仅标记最后一个点,只需node [anchor=south] {\pgfmathprintnumber[1000 sep=\,]{\pgfplotspointrawy}}在命令末尾添加\addplot

\documentclass[border=5mm]{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{loglogaxis}[visualization depends on=rawy \as \pgfplotspointrawy]
\addplot+[] coordinates{(1,1) (2,20) (3,100) (40,4000)} node [anchor=south] {\pgfmathprintnumber[1000 sep=\,]{\pgfplotspointrawy}};
\end{loglogaxis}
\end{tikzpicture}
\end{document}

相关内容