显示轴上的坐标

显示轴上的坐标

如何在 Pgfplots 对数-对数图上显示列出点的坐标?

另外,我怎样才能用不同的名称标记表格给出的每个图表?

\begin{tikzpicture}
\begin{axis}[
xmode=log, 
ymode=log, 
xlabel=Processors, 
ylabel=Speedup
]

\addplot table {
1 1
2 1.99892449476752
4 3.96674166623464
8 7.88161642065569
16 15.4344468776274
32 12.4017223883252
64 24.0354227021333
};

\addplot table {
1 1
2 1.99804684248206
4 5.34549214847199
8 7.94496112836762
16 15.7551224031058
32 22.774653408508
64 40.4820003069663
};

\addplot table {
1 1
2 2.00359505426647
4 3.87681649751088
8 7.94921166729328
16 15.7830470707627
32 28.9132497101297
64 56.1481274839776
};

\addplot table {
1 1
2 1.99397507855784
4 3.98192544925128
8 7.98048783262623
16 15.8061179993891
32 30.4545364844811
64 59.9506057736665
};
\end{axis}
\end{tikzpicture}

以下是 x 轴上标记的坐标的示例:

在此处输入图片描述

理想情况下,应该在 y 轴上实现类似的效果,但我不确定如果两个点很接近,则很难区分。

答案1

我不知道是否存在比建议的更简单的方法这个很好的答案,但使用此方法您可以执行以下操作:

\documentclass[border=10pt]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18} 

\begin{document}

\begin{tikzpicture}
\begin{axis}[
xmode=log, 
ymode=log, 
xlabel=Processors, 
ylabel=Speedup,
xtick={data},
xticklabel={%
    \pgfkeys{/pgf/fpu=true}%
    \pgfmathparse{exp(\tick)}%
    \pgfmathprintnumber[fixed relative, precision=3]{\pgfmathresult}%
    \pgfkeys{/pgf/fpu=false}%
},
]

\addplot table {
1 1
2 1.99892449476752
4 3.96674166623464
8 7.88161642065569
16 15.4344468776274
32 12.4017223883252
64 24.0354227021333
};

\addplot table {
1 1
2 1.99804684248206
4 5.34549214847199
8 7.94496112836762
16 15.7551224031058
32 22.774653408508
64 40.4820003069663
};

\addplot table {
1 1
2 2.00359505426647
4 3.87681649751088
8 7.94921166729328
16 15.7830470707627
32 28.9132497101297
64 56.1481274839776
};

\addplot table {
1 1
2 1.99397507855784
4 3.98192544925128
8 7.98048783262623
16 15.8061179993891
32 30.4545364844811
64 59.9506057736665
};
\end{axis}
\end{tikzpicture}

\end{document}

在此处输入图片描述

相关内容