# Cant scale x-Axis to textwidth

I want to plot some measured values. The y-axis contains the the voltage and the x-axis time stamps. I used matlab2tikz to create this plot:

If I want to plot the graph, the x-axis is not scaled to the textwidht. How can I scale it so that the complete textwidht is used between xmin and xmax ?

Thanks for all the suggestions

\documentclass{article}
\usepackage{pgfplots}
\usetikzlibrary{plotmarks}

\newlength\figureheight
\newlength\figurewidth

\begin{document}
\setlength\figureheight{0.35\textheight}
\setlength\figurewidth{0.9\textwidth}

\begin{tikzpicture}

\begin{axis}[%
width=\figurewidth,
height=\figureheight,
unbounded coords=jump,
view={0}{90},
%scale only axis,
%xscale=1,
xmin=735340.365497685,
xmax=735340.875439815,
xtick=    {735340.465497685,735340.4999357,735340.534373714,735340.568811728,735340.603249743,73534    0.637687757,735340.672125772,735340.706563786,735340.7410018,735340.775439815},
xticklabels=    {11:10:19,11:59:54,12:49:29,13:39:05,14:28:40,15:18:16,16:07:51,16:57:27,17:47:02,18:36:3    8},
%enlargelimits=false,
ymin=46,
ymax=58,
ylabel={Spannung [V]},
%zmin=-1,
%zmax=2,
name=plot1
]
color=blue,
solid,
forget plot
]
table[row sep=crcr]{
735340.464791667 49.9\\
735340.465497685 49.9\\
735340.466203704 49.9\\
735340.466909722 49.9\\
735340.467615741 49.9\\
735340.468310185 49.9\\
735340.469050926 49.9\\
735340.469756944 49.9\\
735340.470451389 49.9\\
735340.471157407 49.7\\
735340.471863426 49.5\\
735340.472569444 48.8\\
735340.473263889 49.2\\
735340.473969907 48.8\\
735340.474675926 48.4\\
735340.475381944 48.4\\
735340.476111111 48.3\\
735340.47681713 48.1\\
735340.477523148 48\\
735340.478217593 47.8\\
735340.478923611 48\\
735340.479618056 49.1\\
735340.480324074 49.4\\
735340.481030093 49.3\\
735340.481724537 49.2\\
735340.482430556 48.6\\
735340.483171296 48.7\\
735340.483877315 48.7\\
735340.484583333 50.6\\
735340.485277778 53.6\\
735340.485983796 54.3\\
735340.486689815 53.4\\
735340.487384259 53.9\\
735340.488090278 54.4\\
735340.488796296 54.5\\
735340.489502315 54.5\\
735340.490231482 54.5\\
735340.490925926 54.4\\
735340.491631944 54.5\\
735340.492337963 54.5\\
735340.493032407 54.5\\
735340.493738426 54.5\\
735340.49443287 54.5\\
735340.495138889 54.6\\
735340.495833333 54.6\\
735340.496585648 54.6\\
735340.497291667 54\\
};
\end{axis}
\end{tikzpicture}
\end{document}

-
When you use the matlab2TikZ function, do you first set the plot in full screen? Or do you save the plot when it is in the small squared window of matlab? –  Ludovic C. Jun 20 '13 at 17:16
I tried both. But the results are the same. –  schmokie Jun 20 '13 at 17:38
Playing a little bit with your code I found that if you change the xticks vector you can get something which responds to changes in the value of \figurewidth. Isn't it possible to spread the x-values for having bigger intervals between the x ticks? By applying a linear transformation which gives xmin=0 and xmax=10 or 100? –  Ludovic C. Jun 20 '13 at 17:43
When compiling your code I get the "Dimension too large" error from pgfplots. I looked up what that means and what can be the reason for this error. Page 8-9 of this link :iro.umontreal.ca/~simardr/pgfplots.pdf . You should really try to adapt your x-scale in order to reduce the number of digit after the coma. –  Ludovic C. Jun 20 '13 at 18:00
Dam, I tried somthing like this before, but it thims that the differnenz wasn't big enought. –  schmokie Jun 20 '13 at 18:24

The problem is coming from the pgfplots package when an axis contains values with too many figures (see the manual for more details). A way to solve this is to rescale the xticks values and the x coordinates of the points to plot with matlab. This can be done by using a linear function looking like
Then if you do not touch to the xticklabels this transformation will be transparent on the pdf but will allow to get rid of the error "Dimension too large" from the pgfplots package. This should also allow you to get some response from the figure when modifying its width.