我对绘制图表还很陌生。我有下表:
\begin{tabular}{rrrr}
\firstrow Frequency/[Hz] & $V_{pp}$/[V] & $V_{rms}$ DMM/[V] & $V_{rms}$ scope/[V] \\
50 & 0.800 & 0.28135 & 0.283 \\
100 & 0.800 & 0.28145 & 0.283 \\
200 & 0.808 & 0.28150 & 0.286 \\
500 & 0.808 & 0.28152 & 0.286 \\
1000 & 0.808 & 0.28153 & 0.286 \\
2000 & 0.808 & 0.28153 & 0.286 \\
5000 & 0.808 & 0.28157 & 0.286 \\
10000 & 0.808 & 0.28140 & 0.286 \\
100000 & 0.808 & 0.28027 & 0.286 \\
200000 & 0.816 & 0.27254 & 0.288 \\
300000 & 0.808 & 0.24229 & 0.286 \\
400000 & 0.816 & 0.19153 & 0.288 \\
500000 & 0.800 & 0.14047 & 0.283 \\
\end{tabular}
我希望用这个制作一个散点图,结果就像这样(在 Excel 中制作的图表):
如何直接在 LaTeX 中重新创建该图表?x 轴是频率,y 轴是第 3 列和第 4 列的值,因此是 V_rms 列。
答案1
这将帮助你开始
\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotstableread[header=false]{
50 0.800 0.28135 0.283
100 0.800 0.28145 0.283
200 0.808 0.28150 0.286
500 0.808 0.28152 0.286
1000 0.808 0.28153 0.286
2000 0.808 0.28153 0.286
5000 0.808 0.28157 0.286
10000 0.808 0.28140 0.286
100000 0.808 0.28027 0.286
200000 0.816 0.27254 0.288
300000 0.808 0.24229 0.286
400000 0.816 0.19153 0.288
500000 0.800 0.14047 0.283
}\mytable
\begin{document}
\begin{tikzpicture}
\begin{loglogaxis}[xminorgrids,
ymax=1,
ymin=0.1,
legend entries={$V_{rms}$ DMM [V],$V_{rms}$ Scope[V]},
legend style={at={(axis description cs:1.05,0.5)},anchor=west,draw=none},
log base 10 number format code/.code={% There was an options for this?
\pgfkeys{/pgf/fpu}\pgfmathparse{10^#1}%
\pgfmathprintnumber[fixed,1000 sep=]{\pgfmathresult}%
}
]
\addplot[blue!60,only marks,mark=diamond*] table[x index=0,y index=2]\mytable;
\addplot[green,
only marks,
mark=square*,
mark size=3pt,
] table[x index=0,y index=3]\mytable;
\end{loglogaxis}
\end{tikzpicture}
\end{document}