# Chart with long x axis text labels looks ugly

Thanks to Caramdir and Alan Munn I am now able to create basic bar charts that use text as x axis labels. Functionally they are perfect, but some of them look kind of ugly. See for yourself:

\documentclass{article}
\usepackage{pgfplots}

\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}
\begin{axis}[
width=15cm,
height=8cm,
symbolic x coords={elso es masodrendu varosok,
falu es varos kozti atmenet,
funkcionalis ertelemben nem varos},
x tick label style={font=\small},
xtick=data,
ymin=0,
ymax=65,
ylabel=\%,
ylabel style={rotate=-90},
ybar,
bar width=45pt,
]
(elso es masodrendu varosok,36)
(falu es varos kozti atmenet,4)
(funkcionalis ertelemben nem varos,60)};
\end{axis}
\end{tikzpicture}
\end{figure}
\end{document}

% I have removed all non-English characters from the sample code
% but the image below was generated with the original strings.


Now, the chart has everything I need, but it would look much prettier if I could break the text labels into at least two lines and move the two side bars closer to the center bar. Unfortunately, {falu es varos\\kozti atmenet} is not usable as a valid x coordinate.

And I have also been unable to find a way to explicitly set spacing between the bars when using non-numeric coordinates. I tried to set the bar width to a bigger value thus forcing them closer to each other, but it does not work. The bars get fatter but they keep their positions.

Any help would be much appreciated.

-

You can add the key text width=<dimension>,align=center to the x tick label style option to make the tick labels wrap and center.

Decreasing the width of the plot then moves the columns closer together. By introducing enlarge x limits=<value>, you can move the outer columns closer to the center.

\documentclass{article}
\usepackage{pgfplots}

\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}
\begin{axis}[
width=8cm,
height=8cm,
symbolic x coords={elso es masodrendu varosok,
falu es varos kozti atmenet,
funkcionalis ertelemben nem varos},
x tick label style={font=\small,text width=1.7cm,align=center},
xtick=data,
ymin=0,
ymax=65,
ylabel=\%,
ylabel style={rotate=-90},
ybar,
enlarge x limits=.3,
bar width=45pt,
]