# How can I minimize the distance between 2 values on the x-axis?

I am totally new to pgf plots...

My plot looks like this right now:

How can I minimize the distance between "EOD" und "LOD"?

That is my code:

\begin{axis}[height=6cm,
ybar stacked,
ylabel=Anzahl,
xlabel=Serotypen,
xtick={EOD,LOD},
symbolic x coords={EOD,LOD},
legend cell align=left,
enlargelimits={abs=10pt},
legend style={at={(1.4,0.8)},anchor=west},
legend entries={PI-2a, PI-2b, PI-2a und PI-1, PI-2b und PI-1}];
%
\end{axis}
\end{tikzpicture}
\end{figure}


How can I generally define the distance between 2 x ticks? E.g. if they are too close?

Each single *.txt file looks like this:

EOD/LOD Anzahl

EOD 6

LOD 3

• Please complete your code to something compilable. Thanks. – LaRiFaRi Jun 25 '14 at 10:23
• We don't know what your data looks like. But if you are specifying x values in there, you should try xtick=data instead of xtick={EOD,LOD},. – LaRiFaRi Jun 25 '14 at 10:35
• I tried the command xtick=data and xtick={EOD,LOD} but nothing changed – Kate Jun 25 '14 at 12:18
• We still don't know everything, as your example stays uncompilable. Please edit your question. – LaRiFaRi Jun 25 '14 at 13:26

As you don't have any x values, pgfplots decides for you, where to put the bars. I guess, there is a recommended distance to the sides. Therefore, the first step could be, to reduce the total width of your plot in order to get a nicer look. If you want to keep this size, you may introduce a fixed enlargement to both sides of your x "values". Here, I inserted the TikZ-measure 1. You may play around with this value and use units such as cm, in, pt... You already hat some enlargement defines. I do not know, if you really need it so I adapted it for the y axis only.

% arara: pdflatex

\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.10}
\usepackage{filecontents}
\begin{filecontents*}{dummy1.txt}
EOD/LOD Anzahl

EOD 6

LOD 3
\end{filecontents*}
\begin{filecontents*}{dummy2.txt}
EOD/LOD Anzahl

EOD 2

LOD 0.5
\end{filecontents*}

\begin{document}
\begin{figure}
\begin{tikzpicture}
\begin{axis}[
,height=6cm
%,width=5cm % you can adapt you total width here, if you like.
,ybar stacked
,ylabel=Anzahl
,xlabel=Serotypen
,xtick=data % more flexible, but the same result here.
,symbolic x coords={EOD,LOD}
,legend cell align=left
,enlarge y limits={abs=30pt} % Don't know, if still needed. You can take it away, if you don't need enlargment in y direction.