9

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}
  • 2
    You would have to edit the My_Picture.tikz I guess, that is just a text file containing a tikzpicture with an axis environment. See the pgfplots manual. – Torbjørn T. Oct 1 '12 at 8:58
6

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

6

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.

4

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.

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.