6

I have a grouped bar-chart, in which I would like to highlight in some way the two bars corresponding to EU-24. Perhaps by giving them a different colour, or pattern. Does anything jump to mind?

enter image description here

\documentclass[tikz,border={38pt 12pt}]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\usetikzlibrary{plotmarks}\definecolor{mycolor1}{rgb}{0,0,0.5625}

\begin{document}
\begin{tikzpicture}[trim axis left, trim axis right]

\begin{axis}[%
width=4.78723958333333in,
height=1.96484375in,
area legend,
scale only axis,
xmin=0,
xmax=12,
xtick={1,2,3,4,5,6,7,8,9,10,11},
xticklabels={IRL,EST,GRC,LTU,CZE,DNK,SVN,ESP,EU-24,GBR,CZE},
xlabel={Country Initials},
ymin=-10,
ymax=10,
ylabel={Percentage},
legend style={draw=black,fill=white,legend cell align=left}
]
\addplot[ybar,bar width=0.0911855158730159in,bar shift=-0.0569909474206349in,fill=mycolor1,draw=black] plot coordinates{(1,6.50839602446152)
(2,7.18649865479679)
(3,5.69926104853342)
(4,8.86318406286013)
(5,5.96722429393004)
(6,3.21245636089815)
(7,3.90148651103934)
(8,4.11307588009999)
(9,4.55138638324477)
(10,4.87923265464318)
(11,2.66698448311287)};

\addlegendentry{2000-2009};

\addplot [
color=black,
solid,
forget plot
]
table[row sep=crcr]{
0 0\\
12 0\\
};
\addplot[ybar,bar width=0.0911855158730159in,bar shift=0.0569909474206349in,fill=red!50!black,draw=black] plot coordinates{(1,-7.93058315856087)
(2,-7.26040844811857)
(3,-6.67854407923318)
(4,-5.0031445973415)
(5,-4.37613983512456)
(6,-2.10591746017944)
(7,-2.00034271729993)
(8,-0.903233231259903)
(9,-0.631822488660329)
(10,-0.47632641303218)
(11,-0.222157097491837)};

\addlegendentry{2009-2012};

\end{axis}
\end{tikzpicture}%
\end{document}
6

The easiest way is to remove the EU-24 points from your \addplot commands and to add 2 new \addplot. It is not the most elegant solution but it does what you want.

enter image description here

\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\usetikzlibrary{plotmarks}\definecolor{mycolor1}{rgb}{0,0,0.5625}

\begin{document}

\begin{tikzpicture}[trim axis left, trim axis right]

\begin{axis}[%
width=4.78723958333333in,
height=1.96484375in,
area legend,
scale only axis,
xmin=0,
xmax=12,
xtick={1,2,3,4,5,6,7,8,9,10,11},
xticklabels={IRL,EST,GRC,LTU,CZE,DNK,SVN,ESP,EU-24,GBR,CZE},
xlabel={Country Initials},
ymin=-10,
ymax=10,
ylabel={Percentage},
legend style={draw=black,fill=white,legend cell align=left}
]
\addplot[ybar,bar width=0.0911855158730159in,bar shift=-0.0569909474206349in,fill=mycolor1,draw=black] plot coordinates{(1,6.50839602446152)
(2,7.18649865479679)
(3,5.69926104853342)
(4,8.86318406286013)
(5,5.96722429393004)
(6,3.21245636089815)
(7,3.90148651103934)
(8,4.11307588009999)
%(9,4.55138638324477)
(10,4.87923265464318)
(11,2.66698448311287)};

\addlegendentry{2000-2009};

\addplot [
color=black,
solid,
forget plot
]
table[row sep=crcr]{
0 0\\
12 0\\
};
\addplot[ybar,bar width=0.0911855158730159in,bar shift=0.0569909474206349in,fill=red!50!black,draw=black] plot coordinates{(1,-7.93058315856087)
(2,-7.26040844811857)
(3,-6.67854407923318)
(4,-5.0031445973415)
(5,-4.37613983512456)
(6,-2.10591746017944)
(7,-2.00034271729993)
(8,-0.903233231259903)
%(9,-0.631822488660329)
(10,-0.47632641303218)
(11,-0.222157097491837)};

\addlegendentry{2009-2012};

\addplot[ybar,bar width=0.0911855158730159in,bar shift=0.0569909474206349in,fill=green!50!black,draw=black] plot coordinates{(9,-0.631822488660329)};

\addplot[ybar,bar width=0.0911855158730159in,bar shift=-0.0569909474206349in,fill=green!50!black,draw=black] plot coordinates{(9,4.55138638324477)};

\end{axis}
\end{tikzpicture}%
\end{document}

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.