0

I’m having problem with the scaled ticks options.

I just would like to have 10–5 at the top of the y axis and some numbers along the y axis...

I commented %scaled ticks=true in the attached example of code.

enter image description here

Thanks!

\documentclass[crop]{standalone}

\usepackage{tikz}
\usepackage{amsmath}
\usepackage{amssymb,amsmath}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}

\setlength{\textwidth}{10cm}

\begin{document}

    \begin{tikzpicture}[font={\fontsize{10pt}{3}\selectfont}]
      \begin{axis}[ legend pos = north east, legend columns=1,
      grid=major,
      %scaled ticks=true
      legend cell align=left,
      ymode=log,
      width=\textwidth, ymin=0.00001, ymax=0.00005, xmin=1, xmax=30, 
      ylabel={MSE indices \& SSCRB}, xlabel={Shape parameter: $\lambda$},]
    \addplot[red,mark=square*] table[x={x}, y={y}] {SCM.dat}; \addlegendentry{$\varrho_{SCM}$} ;

    \addplot[blue,mark=*] table[x={x}, y={y}] {Tyler.dat}; \addlegendentry{$\varrho_{Tyler}$} 

    \addplot[green!60!black,mark=diamond*] table[x={x}, y={y}] {SSCRB.dat}; \addlegendentry{$\mathrm{SSCRB}$} ;

    \end{axis}
    \end{tikzpicture}
\end{document}
Vuk
  • 115

1 Answers1

0

Unfortunately if you look in the relevant section of the pgfplots manual (4.15.3) you will find:

manual quote

You could emulate the setting by manually specify ticks positions (ytick) and labels (yticklabels) for the y-axis, and adding a tikz node by the side of the axis:

    \begin{tikzpicture}[font={\fontsize{10pt}{3}\selectfont}]
      \begin{axis}[ legend pos = north east, legend columns=1,
      grid=major,
      % scaled ticks=true, % Doesn't work with log axis
      ytick={0.00001, 0.00001585, 0.00002512, 0.00003981, 0.00005}, % 10^{-5}, 10^{-4.8},...
      yticklabels={1,1.6,2.5,4,5}, % ytick values divided by 10^{-5}
      legend cell align=left,
      ymode=log,
      width=\textwidth, ymin=0.00001, ymax=0.00005, xmin=1, xmax=30, 
      ylabel={MSE indices \& SSCRB}, xlabel={Shape parameter: $\lambda$},]
    \end{axis}
      \node at (-1.2,0) {\(\cdot10^{-5}\)}; % Node to indicate scale factor
    \end{tikzpicture}

output

pip
  • 1,847
  • Ah, ok! Many thanks for your answer! As an alternative to the solution that you suggested, would it be possible to “automatically” display the y tick in a scientific/engineering format (with the 10^{-5} at every tick)? This would be clearer than the default weird format… – Vuk Feb 13 '19 at 09:42
  • That's a good suggestion. I had a go at implementing this but having difficult to get it working as expected. There is a 'log ticks with fixed point' option which is close but doesn't do scientific notation and changing this style does not seem possible. It may well be possible using \pgfmathprintnumber instead - see the answer here: https://tex.stackexchange.com/a/44724/172926 – pip Feb 13 '19 at 14:45