pgfplots
我正在尝试使用仅在小数点后 9 位发生变化的变量绘制图表。但是,我无法让图表正确显示每个单独的点。我尝试了domain y
和y tick
,但没有成功。
代码如下:
\begin{tikzpicture}
\begin{axis}[
axis lines = left,
xlabel = {Number of elements},
ylabel = {$V[\si{\volt}]$},
%ytick={0.0042280430,0.0042280440,0.0042280450,0.0042280460,0.0042280470}
]
\addplot [
color=black,
mark=*
%domain y=(0.0042280435):(0.0042280470)
]
coordinates {
(980, 0.0042280466)
(1247, 0.0042280462)
(2876, 0.0042280438)
(4032, 0.0042280457)
(5264, 0.0042280462)
(5308, 0.0042280462)
};
\end{axis}
\end{tikzpicture}
这就是我所拥有的:
这正是我所寻求的:
我猜是因为 Latex 在某个点之后无法识别小数。那么我该如何强制执行呢?
提前致谢!
答案1
就是这样。准确度有问题,所以你必须取较小的数字。希望你喜欢它!
\documentclass[margin=3mm]{standalone}
\usepackage{pgfplots,pgfplotstable}
\pgfplotsset{compat=newest}
\usepackage{siunitx}
\pgfplotstableread[col sep=comma]{
N, V
980., 42280466.
1247., 42280462.
2876., 42280438.
4032., 42280457.
5264., 42280462.
5308., 42280462.
}\tableNV
\begin{document}
\begin{tikzpicture}
\pgfmathsetmacro{\diff}{42280430.}
\begin{axis}[
axis lines = left,
height=9cm,width=12cm,
xlabel = {Number of elements},
ylabel = {$V[\si{\volt}]$},
/pgf/number format/precision=10,
/pgf/number format/fixed,
/pgf/number format/fixed zerofill,
/pgfplots/xticklabel style={/pgf/number format/.cd,precision=0,1000 sep={},},
ytick={5,10,...,40},yticklabels={0.0042280435,0.0042280440,0.0042280445,0.0042280450,0.0042280455,0.0042280460,0.0042280465,0.0042280470},
xtick={930,1430,...,5430},
domain=9.3e2:5.43e3,
xmin=9.3e2,xmax=5.43e3,
ymin=5.,ymax=40.,
]
\addplot [color=black,only marks,mark=*,mark size=1pt,domain=9.3e2:5.43e3] table[y expr=\thisrow{V}-\diff] {\tableNV};
\end{axis}
\end{tikzpicture}
\end{document}