10

I am having a very hard time trying to figure out how to remove the scientific notations on the y-axis of my graphs. The graphs are made in MATLAB and then converted into TikZ files using the package matlab2tikz. I have added the codes to remove scientific notations in MATLAB, but it seems when I put the tikz files into LaTeX, it automatically recovers the scientific notation format. Any help would be appreciated!

The code I use in LaTeX is as follows

\begin{figure}[H]
\begin{scriptsize}
\begin{center}
\setlength\figureheight{8cm}
\setlength\figurewidth{13cm}
\input{My_Picture.tikz}
\end{center}
\end{scriptsize}
\end{figure}
percusse
  • 157,807

3 Answers3

7

A better way of doing it is to add the options specified in Akk's answer to matlab2tikz's extraAxisOptions property as thus

axoptions={'scaled y ticks = false',...
           'y tick label style={/pgf/number format/.cd, fixed, fixed zerofill,precision=3}'};    
matlab2tikz(FNt,'height','\fh','width','\fw','automaticLabels',true,'showInfo',false,...
                'showWarnings',false,'parseStrings',false,'extraAxisOptions',axoptions);

This has the advantage that it can be done with every figure automatically. I did not include the X-axis options because they were counter-productive in my case.

Milind R
  • 171
7

If it is too laborous to edit all tikz files, you can apply a global setting such that they are applied to each and every plot. Here is an example:

\documentclass{article}

\usepackage{pgfplots,filecontents}
\pgfplotsset{compat=1.6}

% A dummy pgfplots plot with no settings applied
\begin{filecontents*}{My_Picture.tikz}
\begin{tikzpicture}
    \begin{axis}
        \addplot coordinates {(1000,125000)(1500,175000)(900,225000)};
    \end{axis}
\end{tikzpicture}
\end{filecontents*}


% A setting that would be applied to all pgfplots
\pgfplotsset{every axis/.append style={
        scaled y ticks = false, 
        scaled x ticks = false, 
        y tick label style={/pgf/number format/.cd, fixed, fixed zerofill,
                            int detect,1000 sep={\;},precision=3},
        x tick label style={/pgf/number format/.cd, fixed, fixed zerofill,
                            int detect, 1000 sep={},precision=3}
    }
}

\begin{document}
\begin{figure}[H]
\centering
\begin{scriptsize}
    \input{My_Picture.tikz}
\end{scriptsize}
\end{figure}
\end{document}

enter image description here

percusse
  • 157,807
5

One way is to manually edit My_Picture.tikz.

This question is also related to the link how-do-you-remove-the-axis-multiplier.

Within the file My_Picture.tikz you need to add the following within the square brackets of \begin{axis}[...]:

\begin{axis}[ 
  ... ,
  scaled y ticks = false, 
  scaled x ticks = false, 
  y tick label style={/pgf/number format/.cd, fixed, fixed zerofill,precision=3},
  x tick label style={/pgf/number format/.cd, fixed, fixed zerofill,precision=3}
  ]

The above cases removes scientific notation for both axes, and replaces it with a number with 3 decimal digits, and a leading zero if the number is less than 1.

akk
  • 313