3

I know it's possible to format the exponent of the log axis tick marks using log plot exponent style, but this affects both the x and y axes. Is there a way to give different specifications for each. For example, supposed I wanted precision=1 for the y-axis and precision=2 for the x-axis. Is there any way to do this that doesn't involved either manually specifying the axis labels or an excessive amount of code? Thanks for any advice.

example image

\documentclass{article}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
  \begin{loglogaxis}[
    xtick distance=10^(0.25),
    ytickten={0,0.5,...,4.5},
    log plot exponent style/.style={/pgf/number format/.cd,fixed,zerofill,precision=2},
    ]
    \addplot[domain=1:10] {exp(x)};
  \end{loglogaxis}
\end{tikzpicture}
\end{document}

1 Answer 1

3

This was the only way I could make work:

\documentclass[tikz, border=1cm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\begin{document}
\begin{tikzpicture}
\begin{loglogaxis}[
xtickten={0,0.25,...,1},
ytickten={0,0.5,...,4.5},
xticklabel={\pgfkeys{/pgf/number format/.cd,fixed,zerofill,precision=2} $10^{\pgfmathparse{\tick/\logten)}\pgfmathprintnumber{\pgfmathresult}}$},
yticklabel={\pgfkeys{/pgf/number format/.cd,fixed,zerofill,precision=1} $10^{\pgfmathparse{\tick/\logten)}\pgfmathprintnumber{\pgfmathresult}}$},
]
\addplot[domain=1:10] {exp(x)};
\end{loglogaxis}
\end{tikzpicture}
\end{document}

Log-log graph with fixed precision ticks

You must log in to answer this question.

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