平滑的 pgfplots 曲线

平滑的 pgfplots 曲线

我该如何平滑这条曲线?尝试使用 gnuplot,但是不起作用。

\documentclass[convert={density=400,outext=.png}]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\begin{document}
\begin{tikzpicture}[scale=1]
\begin{axis}[line width=2,enlargelimits=false,ylabel=Output Power(dBm)
,xlabel=Control       Voltage(V),
label style={font=\bfseries\Large},
legend style={at={( 0.8,0.2)}, anchor=north west, font=\small},
tick label style={font=\bfseries\large},
grid=major]
\addplot+[no markers, raw gnuplot] gnuplot{plot 'VCO_8hp_2.txt' smooth sbezier;};
\addplot+[no markers, raw gnuplot] gnuplot{plot 'VCO_8hp_2.txt' with points;};
\addlegendentry{$P_o$}
\end{axis}
\end{tikzpicture}
\end{document}

我收到错误消息“抱歉,无法找到 gnuplot 结果文件。”我的数据如下

Control Frequency
0 152.9
0.2 159.3
0.4 165.2
0.6 170.5
0.8 174.8
1 178.2
1.2 180.5
1.4 182
1.6 183
1.8 183.9
2.0 184.5

答案1

正如杰克所说,这应该有效:

\documentclass[convert={density=400,outext=.png}]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\usepackage{filecontents}
\begin{filecontents*}{datafile.dat}
0 152.9
0.2 159.3
0.4 165.2
0.6 170.5
0.8 174.8
1 178.2
1.2 180.5
1.4 182
1.6 183
1.8 183.9
2.0 184.5
\end{filecontents*}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
    line width=2,
    enlargelimits=false,
    ylabel=Output Power(dBm),
    xlabel=Control Voltage(V),
    label style={font=\bfseries\Large},
    legend style={at={( 0.8,0.2)}, anchor=north west, font=\small},
    tick label style={font=\bfseries\large},grid=major
    ]
        \addplot[smooth,mark=*] table {datafile.dat};
\end{axis}
\end{tikzpicture}
\end{document}

图片

相关内容