5

I am using contour maps in pgfplots as part of CAD as well as documentation. Serving both purposes I would like to improve the readability of my contour maps, by multiplying x- or y-axis times a value. Similar for the contour labels.

In this example, I would like an y-axis expressed in MHz instead of Hz (i.e. dividing by 1e6), and also a contour label expressed in muA (i.e. multiplying by 1e6).

What is the best way of doing this?

\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}

and in.data:

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

Examples figures (please excuse me for my poor paint skills): Before

After

1 Answer 1

3

The y axis can be manipulated by:

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

The contour label can be manipulated by:

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

Note the addition of the /pgf/fpu=true in the contour label. Depending on your data this might or not might be necessary.

Result:

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .