2

I need a little help with multiplier format in the PGFplots. The MWE is:

\documentclass{standalone}%
\usepackage{tikz}%
\begin{document}%
    \begin{tikzpicture}[baseline]%,
        \begin{axis}[
            scaled ticks=false,
            clip mode=individual, %
            width=0.55\columnwidth,%
            scale only axis,%
            tick style={color=black},%
            minor y tick num=3,%
            ylabel style={align=center,rotate=-90,overlay},%
            yticklabel style={/pgf/number format/.cd,std,sci zerofill,precision=1,overlay},%
            ytick align=inside,%
            axis y line*=left,%
            minor x tick num=3,%
            xlabel style={align=center,text width=2.5cm},%
            xticklabel style={/pgf/number format/.cd,fixed,fixed zerofill,precision=0},%
            xtick align=inside,%
            axis x line*=bottom,%
            ymin=0, ymax=0.000014,%
            xmin=273.15, xmax=374.15,%
            ]%
            \addplot[domain=273.15:373.15,samples=100]{0.01*101325*((3.6*10^(-7))*(e^(2200*(1/x-1/298.15))))/(-13.85100+0.64038*x-0.00191*x^2+0.00000182110*x^3)};
            \addplot[green,domain=273.15:373.15,samples=100]{0.001*101325*((3.6*10^(-7))*(e^(2200*(1/x-1/298.15))))/(-13.85100+0.64038*x-0.00191*x^2+0.00000182110*x^3)};
        \end{axis}%
    \end{tikzpicture}%
\end{document}%

which leads to the plot: enter image description here

and I would like to have a consistent scientific multiplier through the range of the y-axis. I mean multiplier with same order, 10^5 or 10^6, not both as it's now and of course i don't want to have one multiplier at the top of the y-axis as it can be easily done.

Thank you for your help.

2

In my answer below I scaled each y tick with a certain \exponent of base 10. See the comments in the code for an explanation. For the moment it only works if \tick (after rescaling) is larger than 1. If you try \newcommand{\exponent}{5} it will set the y labels which are <1 to 0, because of int(\tick).

Some other things:

  • I could not run your code with \usepackage{tikz}. You use the axis environment, then you need \usepackage{pgfplots} I think.
  • You can replace axis y line*=left and axis x line*=bottom with axis lines*= left with the same result.
  • You can replace minor y tick num=3 and minor x tick num=3 with minor tick num=3 with the same result.
  • I'm not sure why you redefine the axis label styles. They do not change if I remove them.

MWE

\documentclass{standalone}%
\usepackage{pgfplots}%
\pgfplotsset{compat=1.14}
% Define the exponent of base 10, where to divide each y label with
\newcommand{\exponent}{6}
\begin{document}%
    \begin{tikzpicture}[baseline]%,
        \begin{axis}[
            width=0.55\columnwidth,%
            scale only axis,%
            tick style={color=black}, axis lines*= left,%
            minor tick num=3,%
            % Scale each y label with a certain exponent
            scaled y ticks=base 10:\exponent,
            % Hide the corresponding scaling label ($10^-\exponent$)
            ytick scale label code/.code={},
            yticklabel={\pgfmathparse{int(\tick)}
                % If the tick = 0, just put 0
                \ifnum \pgfmathresult = 0 
                    0
                % Else print the scaled number adding 10^\exponent to each tick
                \else
                    \pgfmathresult $\cdot 10^{-\exponent}$
                \fi},
            ymin=0, ymax=0.000014,%
            xmin=273.15, xmax=374.15,%
            ]%
            \addplot[domain=273.15:373.15,samples=100]{0.01*101325*((3.6*10^(-7))*(e^(2200*(1/x-1/298.15))))/(-13.85100+0.64038*x-0.00191*x^2+0.00000182110*x^3)};
            \addplot[green,domain=273.15:373.15,samples=100]{0.001*101325*((3.6*10^(-7))*(e^(2200*(1/x-1/298.15))))/(-13.85100+0.64038*x-0.00191*x^2+0.00000182110*x^3)};
        \end{axis}%
    \end{tikzpicture}%
\end{document}%

Result

Using width=10 cm:

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.