
私は pgfplots を使用してグラフを描画していますが、プロット時にデータの横座標値を変更したいと考えています。現在、x filter/.code={\pgfmathparse{1/#1} \pgfmathresult}
x 値の逆数を取得するために を使用しています。ただし、この数学演算では精度が不足しているようです。出力が期待どおりではない MWE を以下に示します。
\documentclass[a4paper]{article}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[%
width=10cm,
height=5cm,
]
\addplot [x filter/.code={\pgfmathparse{1/#1} \pgfmathresult}]
table[row sep=crcr]{%
665.123474243553 50.0709210000000\\
665.124802332690 49.6678125000000\\
665.126130403923 49.7686245000000\\
665.127458480460 49.7501640000000\\
665.128786585510 49.6496310000000\\
665.130114672653 49.8061035000000\\
665.131442788313 50.1225825000000\\
665.132770886063 49.5357525000000\\
665.134099012330 49.4506110000000\\
665.135427120687 50.0079600000000\\
665.136755257560 49.0017465000000\\
665.138083376527 49.5523995000000\\
665.139411524010 49.7646720000000\\
665.140739653583 49.7826210000000\\
665.142067788460 49.3249215000000\\
665.143395951857 48.9346470000000\\
665.144724097340 48.6674580000000\\
665.146052271343 48.2280330000000\\
665.147380427437 46.8564690000000\\
665.148708612050 46.2079800000000\\
665.150036778750 44.7215610000000\\
665.151364973970 44.2429365000000\\
665.152693151283 43.3782690000000\\
665.154021357110 44.1923910000000\\
665.155349545030 44.8409730000000\\
665.156677761467 45.3737235000000\\
665.158005959997 46.7979255000000\\
665.159334163827 47.2520910000000\\
665.160662396177 48.7288845000000\\
665.161990610620 48.5122410000000\\
665.163318853580 49.2502890000000\\
665.164647078630 48.5547885000000\\
665.165975332200 49.2531720000000\\
665.167303567860 50.3161155000000\\
665.168631832037 49.4624685000000\\
665.169960078307 49.6258695000000\\
665.171288353093 50.0582730000000\\
665.172616609973 49.7700195000000\\
665.173944872157 49.7608590000000\\
665.175273162857 49.8229830000000\\
665.176601435650 49.8743190000000\\
665.177929736963 49.8491160000000\\
};
\end{axis}
\end{tikzpicture}
\end{document}
精度を向上させる方法はありますか?
ソリューションを編集:
\documentclass[a4paper]{article}
\usepackage{pgfplots,xfp}
\begin{document}
\begin{tikzpicture}
\begin{axis}[%
width=10cm,
height=5cm,
xticklabel style={/pgf/number format/fixed,/pgf/number format/precision=6, rotate=45}
]
\addplot [x filter/.code={\def\pgfmathresult{\fpeval{1/#1}}}]
table[row sep=crcr]{%
665.123474243553 50.0709210000000\\
665.124802332690 49.6678125000000\\
665.126130403923 49.7686245000000\\
665.127458480460 49.7501640000000\\
665.128786585510 49.6496310000000\\
665.130114672653 49.8061035000000\\
665.131442788313 50.1225825000000\\
665.132770886063 49.5357525000000\\
665.134099012330 49.4506110000000\\
665.135427120687 50.0079600000000\\
665.136755257560 49.0017465000000\\
665.138083376527 49.5523995000000\\
665.139411524010 49.7646720000000\\
665.140739653583 49.7826210000000\\
665.142067788460 49.3249215000000\\
665.143395951857 48.9346470000000\\
665.144724097340 48.6674580000000\\
665.146052271343 48.2280330000000\\
665.147380427437 46.8564690000000\\
665.148708612050 46.2079800000000\\
665.150036778750 44.7215610000000\\
665.151364973970 44.2429365000000\\
665.152693151283 43.3782690000000\\
665.154021357110 44.1923910000000\\
665.155349545030 44.8409730000000\\
665.156677761467 45.3737235000000\\
665.158005959997 46.7979255000000\\
665.159334163827 47.2520910000000\\
665.160662396177 48.7288845000000\\
665.161990610620 48.5122410000000\\
665.163318853580 49.2502890000000\\
665.164647078630 48.5547885000000\\
665.165975332200 49.2531720000000\\
665.167303567860 50.3161155000000\\
665.168631832037 49.4624685000000\\
665.169960078307 49.6258695000000\\
665.171288353093 50.0582730000000\\
665.172616609973 49.7700195000000\\
665.173944872157 49.7608590000000\\
665.175273162857 49.8229830000000\\
665.176601435650 49.8743190000000\\
665.177929736963 49.8491160000000\\
};
\end{axis}
\end{tikzpicture}
\end{document}
答え1
xfpではこうなります
\documentclass[a4paper]{article}
\usepackage{pgfplots,xfp}
\begin{document}
\begin{tikzpicture}
\begin{axis}[%
width=10cm,
height=5cm,
]
\addplot [x filter/.code={\fpeval{1/#1}}]
table[row sep=crcr]{%
665.123474243553 50.0709210000000\\
665.124802332690 49.6678125000000\\
665.126130403923 49.7686245000000\\
665.127458480460 49.7501640000000\\
665.128786585510 49.6496310000000\\
665.130114672653 49.8061035000000\\
665.131442788313 50.1225825000000\\
665.132770886063 49.5357525000000\\
665.134099012330 49.4506110000000\\
665.135427120687 50.0079600000000\\
665.136755257560 49.0017465000000\\
665.138083376527 49.5523995000000\\
665.139411524010 49.7646720000000\\
665.140739653583 49.7826210000000\\
665.142067788460 49.3249215000000\\
665.143395951857 48.9346470000000\\
665.144724097340 48.6674580000000\\
665.146052271343 48.2280330000000\\
665.147380427437 46.8564690000000\\
665.148708612050 46.2079800000000\\
665.150036778750 44.7215610000000\\
665.151364973970 44.2429365000000\\
665.152693151283 43.3782690000000\\
665.154021357110 44.1923910000000\\
665.155349545030 44.8409730000000\\
665.156677761467 45.3737235000000\\
665.158005959997 46.7979255000000\\
665.159334163827 47.2520910000000\\
665.160662396177 48.7288845000000\\
665.161990610620 48.5122410000000\\
665.163318853580 49.2502890000000\\
665.164647078630 48.5547885000000\\
665.165975332200 49.2531720000000\\
665.167303567860 50.3161155000000\\
665.168631832037 49.4624685000000\\
665.169960078307 49.6258695000000\\
665.171288353093 50.0582730000000\\
665.172616609973 49.7700195000000\\
665.173944872157 49.7608590000000\\
665.175273162857 49.8229830000000\\
665.176601435650 49.8743190000000\\
665.177929736963 49.8491160000000\\
};
\end{axis}
\end{tikzpicture}
\end{document}