# x-axis values are very close to each other

For the MWE below:

\documentclass{report}
\usepackage[left=2.5cm,right=2cm,top=2cm,bottom=2cm]{geometry}
\usepackage[T1]{fontenc}
\usepackage{pgfplots}

\begin{document}

\begin{figure}[H]
\centering
\begin{tikzpicture}
\begin{axis}[
ybar,
scaled y ticks = true,
ymajorgrids,
yminorgrids,
minor y tick num=5,
ylabel={Time Elapsed (in hours)},
xlabel={Methods},
width=1*\textwidth,
height=9cm,
bar width=4pt,
symbolic x coords={3,4,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35
},
xtick=data,
ymin=0
%nodes near coords,
%nodes near coords align={vertical},
]
coordinates {(3,38.9575) (4,166.897) (6,53.63835) (7,39.6594) (8,82.1631) (9,40.22045) (10,37.2932) (11,131.62625) (12,472.6995) (13,149.837) (14,113.445) (15,108.474) (16,155.24455) (17,95.41392) (18,186.819) (19,153.383) (20,313.361) (21,180.1305) (22,401.3485) (23,1621.092) (24,1929.3) (25,899.283) (26,726.926) (27,1624.4) (28,870.348) (29,979.472) (30,869.418) (31,274.83) (32,1945.87) (33,1359.09) (34,891.24) (35,1625.31)     };
\end{axis}
\end{tikzpicture}
\caption{}
\end{figure}

\end{document}

This one looks OK here but when I put this bar chart in the real document the x-axis values come closer to each other (for example 22,23 are almost touching each other). I am not sure why it only happens there though. Maybe it's the preamble ? Any ideas ?

EDIT: In the actual document it looks like this although the difference is little the bars are a bit closer to each (At least that's what I see :)

-
What do you mean by 'real document'? Did you shrink the width of the plot? – Count Zero Sep 1 '12 at 12:03
I mean this is only an excerpt from the document with a shortened preamble.. No I didn't it's exactly the same width – Cemre Sep 1 '12 at 12:05
I don't see any problems at 22-23. Do you use symbolic coords just because you have skipped x=5? – percusse Sep 1 '12 at 12:07
yes, otherwise there is an empty space at x=5. In this one there are no problems but when I copy paste the thing in the actual document it changes. I updated the question with the image – Cemre Sep 1 '12 at 12:13
I think an empty space at 5 is more informative but otherwise I would hack it by adding x post scale=1.1, enlarge x limits=0.01, width=0.8\textwidth, options. Or reducing the font size of the labels. – percusse Sep 1 '12 at 12:34

I used enlarge x limits=0.015 and tick label style={font=\footnotesize} to reduce the font size used for the labels and to control the x axis enlargement:

\documentclass{report}
\usepackage[left=2.5cm,right=2cm,top=2cm,bottom=2cm]{geometry}
\usepackage[T1]{fontenc}
\usepackage{pgfplots}

\begin{document}

\begin{figure}[H]
\centering
\begin{tikzpicture}
\begin{axis}[
ybar,
scaled y ticks = true,
ymajorgrids,
yminorgrids,
minor y tick num=5,
ylabel={Time Elapsed (in hours)},
xlabel={Methods},
width=1*\textwidth,
height=9cm,
bar width=4pt,
symbolic x coords={3,4,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35
},
xtick=data,
ymin=0,
enlarge x limits=0.015,
tick label style={font=\footnotesize}
%nodes near coords,
%nodes near coords align={vertical},
]