# Problem with xticks when importing Matlab figures using matlab2tikz

When importing the following figure

using the Matlab2Tikz, I obtain the following output , with the xticks strangely exported . Does any one have an idea how I can prevent this? Maybe by passing an extra inut to the matlab2tikz function?

Hier is a simple Matlab Code :

close all
x=linspace(5*10^-2,10*10^-2);
y1=-4*10^5*x+2;
y2=-4*10^5*x+1;
figure;
subplot(121);plot(x,y1);xlabel('x');ylabel('y')
subplot(122);plot(x,y2);xlabel('x');ylabel('y')
matlab2tikz('Test.tikz','standalone', true,'extraAxisOptions','label style={font=\Large}')


The obtained *.Tikz file without the data:

\documentclass[tikz]{standalone}
\usepackage{pgfplots}
\usepackage{amsmath}
\begin{document}
\begin{tikzpicture}

\begin{axis}[%
width=1.95217803030303in,
height=3.565625in,
scale only axis,
xmin=0.04,
xmax=0.1,
xlabel={x},
ymin=-40000,
ymax=-15000,
ylabel={y},
name=plot1,
label style={font=\Large}
]
color=blue,
solid,
forget plot
]
table[row sep=crcr]{

• Could you add a minimal working example (MWE) of the Matlab code you're using to generate the Matlab figure, as well as the matlab2tikz command? This might make it easier for us to identify the problem. – eiterorm May 20 '14 at 8:34
• Why is it strange that the xlabels are exported from MATLAB? Is this not expected? I think the simplest solution would be to refrain from setting xlabel in MATLAB. Or call matlab2tikz before adding the xlabels, if they are required for your visualization in MATLAB. – Paul Gessler May 20 '14 at 17:55
• I think what the question actually means is xtick and not xlabel. – Ali May 20 '14 at 17:59
• @Ali, if that's the case, xticklabel style={/pgf/number format/fixed} should be added to the value of matlab2tikz's 'extraAxisOptions' key. – Paul Gessler May 20 '14 at 18:11
• @PaulGessler Sorry, as Ali said, I meant the xticks . – user2536125 May 21 '14 at 11:20

You can scale your ticks to get rid of powers of 10 and get a more elegant look on your axes. Alternatively, as Paul Gessler suggested, you can also use fixed formatting with desired precision. The example below gives you the idea.

\documentclass[tikz,border=2pt]{article}

\usepackage{pgfplots}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
\begin{axis}[%
width=2in,
height=3in,
xlabel={$x$},
ylabel={$x^2$},
ylabel near ticks,
every axis label/.style={font=\small},
scaled x ticks=base 10:2,
scaled y ticks=base 10:-3,
every tick label/.style={font=\footnotesize},
tick scale binop=\times,
title={With scaled x ticks},
title style={above=1.5ex},
]
\end{axis}
\end{tikzpicture}
%
\begin{tikzpicture}
\begin{axis}[%
width=2in,
height=3in,
xlabel={$x$},
xticklabel style={
/pgf/number format/precision=2,
/pgf/number format/fixed,
/pgf/number format/fixed zerofill,
},
ylabel={$x^2$},
ylabel near ticks,
every axis label/.style={font=\small},
every tick label/.style={font=\footnotesize},
tick scale binop=\times,
title={With fixed x ticks},
title style={above=1.5ex},
]