![使用原始 gnuplot 的 pgfplots 中的錯誤欄](https://rvso.com/image/309856/%E4%BD%BF%E7%94%A8%E5%8E%9F%E5%A7%8B%20gnuplot%20%E7%9A%84%20pgfplots%20%E4%B8%AD%E7%9A%84%E9%8C%AF%E8%AA%A4%E6%AC%84.png)
我總是將 pgfplots 與“raw gnuplot”選項結合使用,因為我更喜歡使用 gnuplot 預處理資料。 (曲線擬合、複雜計算等)
現在我遇到了一個問題,因為我嘗試將錯誤欄新增到我的圖中,仍然使用「raw gnuplot」選項。我檢查了手冊並在互聯網上搜索了解決方案,我發現的只是一種不太令人滿意的解決方案:
% !TeX TXS-program:compile = txs:///pdflatex/[--shell-escape --synctex=1 --interaction=nonstopmode]
\documentclass{article}
\usepackage{pgfplots}
\usepackage{filecontents}
\begin{filecontents*}{data.dat}
#x y x_err y_err
1 2 0.5 0.5
2 8 0.3 0.3
3 9 0.7 0.3
4 1 0.5 0.5
5 2 0.5 0.9
\end{filecontents*}
\begin{document}
\begin{tikzpicture}
\begin{axis}
\addplot gnuplot [
draw=none,
mark=none,
forget plot,
raw gnuplot,
] {
plot 'data.dat' using 1:2:3:4 with xyerrorbars;
};
\addplot+ [
error bars/.cd,
y dir=both,y explicit,
x dir=both,x explicit,
] table [
x error expr=((\thisrowno{3}-\thisrowno{2})/2),
y error expr=((\thisrowno{5}-\thisrowno{4})/2),
]{\jobname.pgf-plot.table};
\end{axis}
\end{tikzpicture}
\end{document}
任何人都可以幫助我找到一個解決方案,可以在使用“原始 gnuplot”時添加錯誤欄,並且不需要第二個“addplot 表”?