4

I have a stacked bar chart and surprisingly not all the percentage of the bars are shown. I only allowed values more than 3% to be shown, however some are clearly more than 3% and at the same time not shown (circled in red). I hope someone can rectify where's the problem. Thanks.

  \documentclass[10pt,twoside,a4paper,fleqn]{report}
\usepackage{xcolor,pgfplots}
\pgfplotsset{compat=1.14}
\begin{document}
\definecolor{BIPV facade}{HTML}{83BA2B}
\definecolor{conventional facade}{HTML}{3b5998}
\definecolor{Column}{HTML}{fa8072}
\definecolor{Core}{HTML}{666666}
\definecolor{Drywall}{HTML}{794044}
\definecolor{Foundation}{HTML}{66cccc}
\definecolor{Roof Construction}{HTML}{daa520}
\definecolor{Slab}{HTML}{ffc3a0}
\definecolor{Window}{HTML}{ff00ff}


\begin{figure}[ht!]
\centering
\begin{tikzpicture}
\begin{axis}[
    xbar stacked,
    legend style={
    legend columns=8,
        at={(xticklabel cs:0.5)},yshift=-5mm,
        anchor=north,
        draw=none
    },
    every node near coord/.style={
    color=black,
      check for zero/.code={
        \pgfkeys{/pgf/fpu=true}
        \pgfmathparse{\pgfplotspointmeta-3}
        \pgfmathfloatifflags{\pgfmathresult}{-}{
           \pgfkeys{/tikz/coordinate}
        }{}
        \pgfkeys{/pgf/fpu=false}
      }, check for zero, xshift=3, font=\scriptsize},
    nodes near coords={\pgfmathprintnumber[fixed zerofill,precision=0]{\pgfplotspointmeta}$\%$},
    nodes near coords align=center,
    ytick=data,
    xtick=data,
    xlabel= Percentage(\%),
    ylabel= Environmental indicators,
    axis y line*=none,
    axis x line*=bottom,
    tick label style={font=\footnotesize},
    legend style={font=\footnotesize},
    label style={font=\footnotesize},
    xtick={0,10,20,30,40,50,60,70,80,90,100},
    width=.9\textwidth,
    bar width=6mm,
    yticklabels={GWP, ODP, POCP, AP, EP(T), EP(FW), EP(M), ADP, CED},
    xmin=0,
    xmax=100,
    area legend,
    y=8mm,
    enlarge y limits={abs=0.625},
]
\addplot
[conventional facade,fill=conventional facade] 
coordinates
{(9.3,0) (6.7,1) (9.2,2) (13.7,3) (9.5,4) (7.5,5) (10.1,6) (6.9,7) (4.8,8)};
\addplot
[Column,fill=Column] 
coordinates
{(7.6,0) (6.4,1) (7.9,2) (6.3,3) (6.8,4) (8.3,5) (7.1,6) (7.7,7)(4,8)};
\addplot
[Core,fill=Core] 
coordinates
{(21.6,0) (18.3,1) (20.7,2) (16.8,3) (18.8,4) (20,5)(19.2,6)(30.4,7) (11.2,8)};
\addplot
[Drywall,fill=Drywall] 
coordinates
{(10.4,0) (23.3,1) (12.1,2) (17.1,3) (18.8,4) (14.9,5)(15.4,6)(21.3,7) (52.8,8)};
\addplot
[Foundation,fill=Foundation] 
coordinates
{(3.1,0) (1.9,1) (1.9,2) (1.6,3) (2.3,4) (1.0,5)(2.2,6)(1.4,7) (1.4,8)};
\addplot
[Roof Construction,fill=Roof Construction] 
coordinates
{(0.2,0) (0.2,1) (0.2,2) (0.2,3) (0.2,4) (0.1,5)(0.2,6)(0.2,7) (0.2,8)};
\addplot
[Slab,fill=Slab]
coordinates
{(38.58,0) (34.48,1) (39.00,2) (31.05,3) (33.96,4) (40.43,5)(35.30,6)(24.43,7) (20.71,8)};
\addplot
[Window,fill=Window] 
coordinates
{(9.15,0) (8.63,1) (9.03,2) (13.30,3) (9.56,4) (7.72,5) (10.49,6)(7.68,7)(4.93,8)};

\legend{Conventional facade, Column, Core, Drywall, Foundation, Roof construction, Slab, Window}
\end{axis}  
\end{tikzpicture}
\end{figure}
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.