I am totally new to pgf plots...

My plot looks like this right now:

My plot looks like this right now:

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

That is my code:

ybar stacked,
symbolic x coords={EOD,LOD},
legend cell align=left,
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}];
\addplot table{./Ergebnisse/K_P_1/PI-2a.txt};
\addplot table{./Ergebnisse/K_P_1/PI-2b.txt};
\addplot table{./Ergebnisse/K_P_1/PI-2a1.txt};
\addplot table{./Ergebnisse/K_P_1/PI-2b1.txt};

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


  • 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

EOD/LOD Anzahl


EOD/LOD Anzahl


LOD 0.5

    %,width=5cm % you can adapt you total width here, if you like.
    ,ybar stacked
    ,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.
    ,enlarge x limits=1 % Adapt enlargment to your needs!
    ,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}
\addplot table{dummy1.txt}; % you have to change these back to your path!
\addplot table{dummy2.txt};

enter image description here

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.