等高线图中的数据处理(x/y 轴和等高线标签)

等高线图中的数据处理(x/y 轴和等高线标签)

我在 pgfplots 中使用等高线图作为 CAD 和文档的一部分。为了达到这两个目的,我想通过将 x 轴或 y 轴乘以一个值来提高等高线图的可读性。等高线标签也类似。

在这个例子中,我想要一个以 MHz 而不是 Hz 表示的 y 轴(即除以 1e6),并且想要一个以 muA 表示的轮廓标签(即乘以 1e6)。

实现这个的最佳方法是什么?

\documentclass[10 pt]{article}
\usepackage{pgfplots,pgfplotstable}

\begin{document}

\pgfplotsset{/pgfplots/ylabel near ticks}
\pgfplotsset{/pgfplots/xlabel near ticks}

\begin{figure}[!htb]
\centering
\begin{tikzpicture}
\pgfplotsset{/pgfplots/height={0.5\linewidth},/pgfplots/width={0.50\linewidth}}
\pgfplotsset{/pgfplots/grid=both}

\pgfplotsset{/pgfplots/xmin=0,/pgfplots/xmax=64}\pgfplotsset{/pgfplots/ymin=10e6,/pgfplots/ymax=80e6}

\begin{axis}
\pgfplotsset{/pgfplots/xlabel={Setting~[-]},/pgfplots/ylabel={$f_\mathrm{clk}$~[Hz]}}
\pgfplotsset{y tick label style={/pgf/number format/fixed, /pgf/number format/fixed zerofill, /pgf/number format/precision=1}}%
\addplot[contour prepared, contour prepared format=matlab] table {in.data} ;
\node[draw,fill=white,below left] at (axis cs:60.8,76.5e6) {$\overline{i_n}$~[A]}; %x/y=x/ymin+0.95*(x/ymax-x/ymin)
\end{axis}

\end{tikzpicture}
\end{figure}

\end{document}

以及数据中:

N FCLK IONOISE(299.0U)
6.71264e-008 7.00000e+000
4.25049e+000 8.00000e+007
4.00000e+000 7.25826e+007
3.75936e+000 7.00000e+007
2.97523e+000 6.00000e+007
2.56914e+000 5.00000e+007
2.23128e+000 4.00000e+007
2.00000e+000 3.55152e+007
8.96947e-008 8.00000e+000
4.89549e+000 8.00000e+007
4.51751e+000 7.00000e+007
4.00000e+000 6.05547e+007
3.95047e+000 6.00000e+007
3.15157e+000 5.00000e+007
2.65600e+000 4.00000e+007
2.17856e+000 3.00000e+007
2.00000e+000 2.82185e+007
1.12263e-007 8.00000e+000
5.54049e+000 8.00000e+007
5.11593e+000 7.00000e+007
4.64471e+000 6.00000e+007
4.00000e+000 5.32484e+007
3.73400e+000 5.00000e+007
3.08073e+000 4.00000e+007
2.71905e+000 3.00000e+007
2.00000e+000 2.28260e+007
1.12263e-007 9.00000e+000
2.00000e+000 1.47692e+007
4.00000e+000 1.23035e+007
8.00000e+000 1.19845e+007
1.20000e+001 1.17485e+007
1.60000e+001 1.15310e+007
2.40000e+001 1.12309e+007
3.20000e+001 1.10640e+007
4.80000e+001 1.12001e+007
6.30000e+001 1.18784e+007
1.34831e-007 1.60000e+001
6.18550e+000 8.00000e+007
5.71435e+000 7.00000e+007
5.32393e+000 6.00000e+007
4.53189e+000 5.00000e+007
4.00000e+000 4.68185e+007
3.50545e+000 4.00000e+007
3.25953e+000 3.00000e+007
3.09663e+000 2.00000e+007
4.00000e+000 1.78323e+007
8.00000e+000 1.72087e+007
1.20000e+001 1.68847e+007
1.60000e+001 1.66026e+007
2.40000e+001 1.61975e+007
3.20000e+001 1.59415e+007
4.80000e+001 1.59494e+007
6.30000e+001 1.65870e+007
1.57400e-007 1.50000e+001
6.83050e+000 8.00000e+007
6.31278e+000 7.00000e+007
6.00314e+000 6.00000e+007
5.51089e+000 5.00000e+007
4.00000e+000 4.09627e+007
3.93018e+000 4.00000e+007
3.80002e+000 3.00000e+007
4.00000e+000 2.62165e+007
8.00000e+000 2.35639e+007
1.20000e+001 2.29105e+007
1.60000e+001 2.24024e+007
2.40000e+001 2.16713e+007
3.20000e+001 2.11784e+007
4.80000e+001 2.10039e+007
6.30000e+001 2.18421e+007
1.79968e-007 1.30000e+001
7.47550e+000 8.00000e+007
6.91120e+000 7.00000e+007
6.68235e+000 6.00000e+007
6.48989e+000 5.00000e+007
6.01208e+000 4.00000e+007
8.00000e+000 3.16148e+007
1.20000e+001 3.03886e+007
1.39444e+001 3.00000e+007
1.60000e+001 2.96802e+007
2.40000e+001 2.88020e+007
3.20000e+001 2.81960e+007
4.80000e+001 2.78283e+007
6.30000e+001 2.85370e+007
2.02537e-007 1.30000e+001
8.26569e+000 8.00000e+007
8.00000e+000 7.81433e+007
7.50963e+000 7.00000e+007
7.36156e+000 6.00000e+007
7.46889e+000 5.00000e+007
8.00000e+000 4.24330e+007
1.14456e+001 4.00000e+007
1.20000e+001 3.97376e+007
1.60000e+001 3.87037e+007
2.40000e+001 3.73836e+007
3.20000e+001 3.64711e+007
4.80000e+001 3.57736e+007
6.30000e+001 3.64698e+007
2.25105e-007 1.00000e+001
9.68777e+000 8.00000e+007
8.51630e+000 7.00000e+007
8.34172e+000 6.00000e+007
1.20000e+001 5.11930e+007
1.41954e+001 5.00000e+007
1.60000e+001 4.92298e+007
2.40000e+001 4.73071e+007
3.20000e+001 4.60255e+007
4.80000e+001 4.49323e+007
6.30000e+001 4.55061e+007
2.47673e-007 9.00000e+000
1.11098e+001 8.00000e+007
1.13758e+001 7.00000e+007
1.20000e+001 6.62073e+007
1.60000e+001 6.18428e+007
2.03345e+001 6.00000e+007
2.40000e+001 5.87223e+007
3.20000e+001 5.69717e+007
4.80000e+001 5.53824e+007
6.30000e+001 5.57459e+007
2.70242e-007 7.00000e+000
1.48022e+001 8.00000e+007
1.60000e+001 7.73011e+007
2.40000e+001 7.19221e+007
2.97562e+001 7.00000e+007
3.20000e+001 6.93481e+007
4.80000e+001 6.71546e+007
6.30000e+001 6.72275e+007

示例图(请原谅我的绘画技巧不佳): 前

后

答案1

y 轴可以通过以下方式操作:

\pgfplotsset{/pgfplots/y filter/.code=\pgfmathparse{##1*1e-6}}

轮廓标签可以通过以下方式操作:

\pgfplotsset{contour/label node code/.code={\node {\pgfkeys{/pgf/fpu=true,/pgf/number format/.cd,precision=2}\pgfmathmultiply{#1}{1e6}\pgfmathprintnumber{\pgfmathresult}};}}

注意轮廓标签中添加的/pgf/fpu=true。根据您的数据,这可能是必要的,也可能不是必要的。

结果:

在此处输入图片描述

相关内容