Pgfplots 및 pgfmathparse, 정밀도 부족

Pgfplots 및 pgfmathparse, 정밀도 부족

나는 그래프를 그리기 위해 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}

관련 정보