1

How could we fix the problem with the x-axis ? Also, would it be possible to have written above or in the middle of each column each number ? enter image description here

So as to make my bar chart, I have used the following code:

\documentclass{article}

\usepackage{pgfplots}

\begin{document}
\begin{tikzpicture}
\begin{axis}[
        width  = 0.85*\textwidth,
        height = 8cm,
        major x tick style = transparent,
        ybar=2*\pgflinewidth,
        bar width=14pt,
        ymajorgrids = true,
        ylabel = {Deaths per 1,000 live births},
        symbolic x coords={World,Low income,Middle income, High income},
        xtick = data,
        scaled y ticks = false,
        enlarge x limits=0.25,
        ymin=0,
        legend cell align=left,
        legend style={
                at={(1,1.05)},
                anchor=south east,
                column sep=1ex
        }
    ]
\addplot
coordinates
{(World,51) (Low income,95) (Middle income,46) (High income,6)};
\addplot
coordinates
{(World,63) (Low income,115) (Middle income,57) (High income,7)};
\addplot
coordinates
{(World,73) (Low income,133) (Middle income,67) (High income,7)};
\addplot
coordinates
{(World,87) (Low income,164) (Middle income,82) (High income,12)};
\legend
{2011,2005,2000, 1990}
\end{axis}
\end{tikzpicture}
\end{document}

1 Answer 1

2

I use option {axis}[nodes near coords, x tick label style={rotate=45,anchor=east},] , maybe you could try in your favor.

  1. nodes near coords add the value for every bars.
  2. x tick label style={rotate=45,anchor=east}, rotate your label with angle 45.

For the bar too wide, I think bar width=12pt is enough. enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .