Axis label is not displayed and adding labels to stacked bar chart











up vote
1
down vote

favorite












I have made this stacked bar chart but I can't get my x-axis label to be shown even though I have added them in the codes. Also, can anyone tell me how can I add labels to my stacked bar chart like in the picture ? Thanks!



enter image description here



documentclass[10pt,twoside,a4paper,fleqn]{report}
usepackage{xcolor,pgfplots}
begin{document}
begin{figure}[ht!]
centering
begin{tikzpicture}
begin{axis}[
xbar stacked,
legend style={
legend columns=4,
at={(xticklabel cs:0.5)},
anchor=north,
draw=none
},
xlabel= Percentage,
ylabel= Environmental indicators,
ytick=data,
xtick=data,
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=.9textwidth,
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
[Construction,fill=Construction]
coordinates
{(7.9,0) (8.8,1) (20.2,2) (28.7,3) (20.5,4) (44.7,5) (17.8,6) (46.6,7) (3.9,8)};
addplot
[Operational,fill=Operational]
coordinates
{(89.7,0) (89.5,1) (76.3,2) (64.5,3) (76.3,4) (50.1,5) (70.5,6) (37.9,7) (95.4,8)};
addplot
[Maintenance,fill=Maintenance]
coordinates
{(1.0,0) (1.5,1) (2.8,2) (6.4,3) (2.9,4) (4.8,5) (3.1,6)(15.3,7) (0.6,8)};
addplot
[Disposal,fill=Disposal]
coordinates
{(1.3,0) (0.2,1) (0.7,2) (0.3,3) (0.3,4) (0.5,5) (8.6,6)(0.1,7) (0.1,8)};

legend{Construction, Operational, Replacement, Disposal}
end{axis}
end{tikzpicture}
caption{Life cycle phase contribution analysis per impact category.\Categories from bottom to the top are Global Warming Potential (ac{GWP}), Ozone Depletion Potential (ac{ODP}), Photochemical Ozone Creation Potential (ac{POCP}), Acidification Potential (ac{AP}), Terrestrial Eutrophication Potential ac{EP(T)}, ac{EP(FW)}, ac{ADP} and ac{CED}.}
label{conventional}
end{figure}
end{document}









share|improve this question
























  • Thanks for providing a MWE. But, please edit your code so that it produces the erroneous result that you describe. As it is, it is not compilable. For instance you have [ where it should just be a [ for optional parameters.
    – Peter Grill
    Nov 20 at 20:51












  • Thanks for the reply. I hope it's correct now.
    – thesilencer
    Nov 20 at 21:49










  • Did you try compiling it?
    – Peter Grill
    Nov 20 at 22:21










  • I'm not quite sure what's the mistake here because I extracted the table from my thesis and it's not exactly the whole thing. Did i miss any package that you can kindly enlighten me on?
    – thesilencer
    Nov 20 at 23:26










  • I get errors when I compile this.Please put this in a separate document and make sure it compiles. For instance, the Construction style is not defined, neither is the Construction color.
    – Peter Grill
    Nov 20 at 23:34















up vote
1
down vote

favorite












I have made this stacked bar chart but I can't get my x-axis label to be shown even though I have added them in the codes. Also, can anyone tell me how can I add labels to my stacked bar chart like in the picture ? Thanks!



enter image description here



documentclass[10pt,twoside,a4paper,fleqn]{report}
usepackage{xcolor,pgfplots}
begin{document}
begin{figure}[ht!]
centering
begin{tikzpicture}
begin{axis}[
xbar stacked,
legend style={
legend columns=4,
at={(xticklabel cs:0.5)},
anchor=north,
draw=none
},
xlabel= Percentage,
ylabel= Environmental indicators,
ytick=data,
xtick=data,
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=.9textwidth,
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
[Construction,fill=Construction]
coordinates
{(7.9,0) (8.8,1) (20.2,2) (28.7,3) (20.5,4) (44.7,5) (17.8,6) (46.6,7) (3.9,8)};
addplot
[Operational,fill=Operational]
coordinates
{(89.7,0) (89.5,1) (76.3,2) (64.5,3) (76.3,4) (50.1,5) (70.5,6) (37.9,7) (95.4,8)};
addplot
[Maintenance,fill=Maintenance]
coordinates
{(1.0,0) (1.5,1) (2.8,2) (6.4,3) (2.9,4) (4.8,5) (3.1,6)(15.3,7) (0.6,8)};
addplot
[Disposal,fill=Disposal]
coordinates
{(1.3,0) (0.2,1) (0.7,2) (0.3,3) (0.3,4) (0.5,5) (8.6,6)(0.1,7) (0.1,8)};

legend{Construction, Operational, Replacement, Disposal}
end{axis}
end{tikzpicture}
caption{Life cycle phase contribution analysis per impact category.\Categories from bottom to the top are Global Warming Potential (ac{GWP}), Ozone Depletion Potential (ac{ODP}), Photochemical Ozone Creation Potential (ac{POCP}), Acidification Potential (ac{AP}), Terrestrial Eutrophication Potential ac{EP(T)}, ac{EP(FW)}, ac{ADP} and ac{CED}.}
label{conventional}
end{figure}
end{document}









share|improve this question
























  • Thanks for providing a MWE. But, please edit your code so that it produces the erroneous result that you describe. As it is, it is not compilable. For instance you have [ where it should just be a [ for optional parameters.
    – Peter Grill
    Nov 20 at 20:51












  • Thanks for the reply. I hope it's correct now.
    – thesilencer
    Nov 20 at 21:49










  • Did you try compiling it?
    – Peter Grill
    Nov 20 at 22:21










  • I'm not quite sure what's the mistake here because I extracted the table from my thesis and it's not exactly the whole thing. Did i miss any package that you can kindly enlighten me on?
    – thesilencer
    Nov 20 at 23:26










  • I get errors when I compile this.Please put this in a separate document and make sure it compiles. For instance, the Construction style is not defined, neither is the Construction color.
    – Peter Grill
    Nov 20 at 23:34













up vote
1
down vote

favorite









up vote
1
down vote

favorite











I have made this stacked bar chart but I can't get my x-axis label to be shown even though I have added them in the codes. Also, can anyone tell me how can I add labels to my stacked bar chart like in the picture ? Thanks!



enter image description here



documentclass[10pt,twoside,a4paper,fleqn]{report}
usepackage{xcolor,pgfplots}
begin{document}
begin{figure}[ht!]
centering
begin{tikzpicture}
begin{axis}[
xbar stacked,
legend style={
legend columns=4,
at={(xticklabel cs:0.5)},
anchor=north,
draw=none
},
xlabel= Percentage,
ylabel= Environmental indicators,
ytick=data,
xtick=data,
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=.9textwidth,
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
[Construction,fill=Construction]
coordinates
{(7.9,0) (8.8,1) (20.2,2) (28.7,3) (20.5,4) (44.7,5) (17.8,6) (46.6,7) (3.9,8)};
addplot
[Operational,fill=Operational]
coordinates
{(89.7,0) (89.5,1) (76.3,2) (64.5,3) (76.3,4) (50.1,5) (70.5,6) (37.9,7) (95.4,8)};
addplot
[Maintenance,fill=Maintenance]
coordinates
{(1.0,0) (1.5,1) (2.8,2) (6.4,3) (2.9,4) (4.8,5) (3.1,6)(15.3,7) (0.6,8)};
addplot
[Disposal,fill=Disposal]
coordinates
{(1.3,0) (0.2,1) (0.7,2) (0.3,3) (0.3,4) (0.5,5) (8.6,6)(0.1,7) (0.1,8)};

legend{Construction, Operational, Replacement, Disposal}
end{axis}
end{tikzpicture}
caption{Life cycle phase contribution analysis per impact category.\Categories from bottom to the top are Global Warming Potential (ac{GWP}), Ozone Depletion Potential (ac{ODP}), Photochemical Ozone Creation Potential (ac{POCP}), Acidification Potential (ac{AP}), Terrestrial Eutrophication Potential ac{EP(T)}, ac{EP(FW)}, ac{ADP} and ac{CED}.}
label{conventional}
end{figure}
end{document}









share|improve this question















I have made this stacked bar chart but I can't get my x-axis label to be shown even though I have added them in the codes. Also, can anyone tell me how can I add labels to my stacked bar chart like in the picture ? Thanks!



enter image description here



documentclass[10pt,twoside,a4paper,fleqn]{report}
usepackage{xcolor,pgfplots}
begin{document}
begin{figure}[ht!]
centering
begin{tikzpicture}
begin{axis}[
xbar stacked,
legend style={
legend columns=4,
at={(xticklabel cs:0.5)},
anchor=north,
draw=none
},
xlabel= Percentage,
ylabel= Environmental indicators,
ytick=data,
xtick=data,
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=.9textwidth,
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
[Construction,fill=Construction]
coordinates
{(7.9,0) (8.8,1) (20.2,2) (28.7,3) (20.5,4) (44.7,5) (17.8,6) (46.6,7) (3.9,8)};
addplot
[Operational,fill=Operational]
coordinates
{(89.7,0) (89.5,1) (76.3,2) (64.5,3) (76.3,4) (50.1,5) (70.5,6) (37.9,7) (95.4,8)};
addplot
[Maintenance,fill=Maintenance]
coordinates
{(1.0,0) (1.5,1) (2.8,2) (6.4,3) (2.9,4) (4.8,5) (3.1,6)(15.3,7) (0.6,8)};
addplot
[Disposal,fill=Disposal]
coordinates
{(1.3,0) (0.2,1) (0.7,2) (0.3,3) (0.3,4) (0.5,5) (8.6,6)(0.1,7) (0.1,8)};

legend{Construction, Operational, Replacement, Disposal}
end{axis}
end{tikzpicture}
caption{Life cycle phase contribution analysis per impact category.\Categories from bottom to the top are Global Warming Potential (ac{GWP}), Ozone Depletion Potential (ac{ODP}), Photochemical Ozone Creation Potential (ac{POCP}), Acidification Potential (ac{AP}), Terrestrial Eutrophication Potential ac{EP(T)}, ac{EP(FW)}, ac{ADP} and ac{CED}.}
label{conventional}
end{figure}
end{document}






tikz-pgf labels axis missing






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 20 at 21:48

























asked Nov 20 at 18:22









thesilencer

766




766












  • Thanks for providing a MWE. But, please edit your code so that it produces the erroneous result that you describe. As it is, it is not compilable. For instance you have [ where it should just be a [ for optional parameters.
    – Peter Grill
    Nov 20 at 20:51












  • Thanks for the reply. I hope it's correct now.
    – thesilencer
    Nov 20 at 21:49










  • Did you try compiling it?
    – Peter Grill
    Nov 20 at 22:21










  • I'm not quite sure what's the mistake here because I extracted the table from my thesis and it's not exactly the whole thing. Did i miss any package that you can kindly enlighten me on?
    – thesilencer
    Nov 20 at 23:26










  • I get errors when I compile this.Please put this in a separate document and make sure it compiles. For instance, the Construction style is not defined, neither is the Construction color.
    – Peter Grill
    Nov 20 at 23:34


















  • Thanks for providing a MWE. But, please edit your code so that it produces the erroneous result that you describe. As it is, it is not compilable. For instance you have [ where it should just be a [ for optional parameters.
    – Peter Grill
    Nov 20 at 20:51












  • Thanks for the reply. I hope it's correct now.
    – thesilencer
    Nov 20 at 21:49










  • Did you try compiling it?
    – Peter Grill
    Nov 20 at 22:21










  • I'm not quite sure what's the mistake here because I extracted the table from my thesis and it's not exactly the whole thing. Did i miss any package that you can kindly enlighten me on?
    – thesilencer
    Nov 20 at 23:26










  • I get errors when I compile this.Please put this in a separate document and make sure it compiles. For instance, the Construction style is not defined, neither is the Construction color.
    – Peter Grill
    Nov 20 at 23:34
















Thanks for providing a MWE. But, please edit your code so that it produces the erroneous result that you describe. As it is, it is not compilable. For instance you have [ where it should just be a [ for optional parameters.
– Peter Grill
Nov 20 at 20:51






Thanks for providing a MWE. But, please edit your code so that it produces the erroneous result that you describe. As it is, it is not compilable. For instance you have [ where it should just be a [ for optional parameters.
– Peter Grill
Nov 20 at 20:51














Thanks for the reply. I hope it's correct now.
– thesilencer
Nov 20 at 21:49




Thanks for the reply. I hope it's correct now.
– thesilencer
Nov 20 at 21:49












Did you try compiling it?
– Peter Grill
Nov 20 at 22:21




Did you try compiling it?
– Peter Grill
Nov 20 at 22:21












I'm not quite sure what's the mistake here because I extracted the table from my thesis and it's not exactly the whole thing. Did i miss any package that you can kindly enlighten me on?
– thesilencer
Nov 20 at 23:26




I'm not quite sure what's the mistake here because I extracted the table from my thesis and it's not exactly the whole thing. Did i miss any package that you can kindly enlighten me on?
– thesilencer
Nov 20 at 23:26












I get errors when I compile this.Please put this in a separate document and make sure it compiles. For instance, the Construction style is not defined, neither is the Construction color.
– Peter Grill
Nov 20 at 23:34




I get errors when I compile this.Please put this in a separate document and make sure it compiles. For instance, the Construction style is not defined, neither is the Construction color.
– Peter Grill
Nov 20 at 23:34










1 Answer
1






active

oldest

votes

















up vote
1
down vote



accepted










It is somewhat hard to write an answer because this requires some fair amount of avoidable extra work. I ended up defining the missing colors somehow, and inventing a command ac. Now to your questions:




  1. You cannot see the xlabel since you put the legend on top. I moved the legend down.

  2. You can add numbers with percentages using nodes near coords. I made a guess which numbers you might be after, and of course this guess is most likely wrong, but perhaps will allow you to modify things in such a way that you get what you want.


Result



documentclass[10pt,twoside,a4paper,fleqn]{report}
usepackage{xcolor,pgfplots}
pgfplotsset{compat=1.16}
definecolor{Construction}{RGB}{184,36,33}
definecolor{Operational}{RGB}{233,171,100}
definecolor{Maintenance}{RGB}{124,174,255}
definecolor{Disposal}{RGB}{185,220,165}
newcommand{ac}[1]{textcolor{red}{#1}}
begin{document}
begin{figure}[ht!]
centering
begin{tikzpicture}
begin{axis}[clip=true,
xbar stacked,
legend style={
legend columns=4,
at={(xticklabel cs:0.5)},yshift=-5mm,
anchor=north,
draw=none
},
ytick=data,
xtick=data,
axis y line*=none,
axis x line*=bottom,
xlabel= Percentage,
ylabel= Environmental indicators,
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=.9textwidth,
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},
visualization depends on=x as rawx,
nodes near coords={pgfmathprintnumber{pgfplotspointmeta}%},
every node near coord/.style={xshift=rawx*1.5pt+0.5cm,text=white},
]
addplot
[Construction,fill=Construction]
coordinates
{(7.9,0) (8.8,1) (20.2,2) (28.7,3) (20.5,4) (44.7,5) (17.8,6) (46.6,7) (3.9,8)};
addplot
[Operational,fill=Operational,nodes near coords={}]
coordinates
{(89.7,0) (89.5,1) (76.3,2) (64.5,3) (76.3,4) (50.1,5) (70.5,6) (37.9,7) (95.4,8)};
addplot
[Maintenance,fill=Maintenance,nodes near coords={}]
coordinates
{(1.0,0) (1.5,1) (2.8,2) (6.4,3) (2.9,4) (4.8,5) (3.1,6)(15.3,7) (0.6,8)};
addplot
[Disposal,fill=Disposal,nodes near coords={}]
coordinates
{(1.3,0) (0.2,1) (0.7,2) (0.3,3) (0.3,4) (0.5,5) (8.6,6)(0.1,7) (0.1,8)};
legend{Construction, Operational, Replacement, Disposal}
end{axis}
end{tikzpicture}
caption{Life cycle phase contribution analysis per impact category.
Categories
from bottom to the top are Global Warming Potential (ac{GWP}), Ozone Depletion
Potential (ac{ODP}), Photochemical Ozone Creation Potential (ac{POCP}),
Acidification Potential (ac{AP}), Terrestrial Eutrophication Potential
ac{EP(T)}, ac{EP(FW)}, ac{ADP} and ac{CED}.}
label{conventional}
end{figure}
end{document}


enter image description here






share|improve this answer























    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "85"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














     

    draft saved


    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f461009%2faxis-label-is-not-displayed-and-adding-labels-to-stacked-bar-chart%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    1
    down vote



    accepted










    It is somewhat hard to write an answer because this requires some fair amount of avoidable extra work. I ended up defining the missing colors somehow, and inventing a command ac. Now to your questions:




    1. You cannot see the xlabel since you put the legend on top. I moved the legend down.

    2. You can add numbers with percentages using nodes near coords. I made a guess which numbers you might be after, and of course this guess is most likely wrong, but perhaps will allow you to modify things in such a way that you get what you want.


    Result



    documentclass[10pt,twoside,a4paper,fleqn]{report}
    usepackage{xcolor,pgfplots}
    pgfplotsset{compat=1.16}
    definecolor{Construction}{RGB}{184,36,33}
    definecolor{Operational}{RGB}{233,171,100}
    definecolor{Maintenance}{RGB}{124,174,255}
    definecolor{Disposal}{RGB}{185,220,165}
    newcommand{ac}[1]{textcolor{red}{#1}}
    begin{document}
    begin{figure}[ht!]
    centering
    begin{tikzpicture}
    begin{axis}[clip=true,
    xbar stacked,
    legend style={
    legend columns=4,
    at={(xticklabel cs:0.5)},yshift=-5mm,
    anchor=north,
    draw=none
    },
    ytick=data,
    xtick=data,
    axis y line*=none,
    axis x line*=bottom,
    xlabel= Percentage,
    ylabel= Environmental indicators,
    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=.9textwidth,
    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},
    visualization depends on=x as rawx,
    nodes near coords={pgfmathprintnumber{pgfplotspointmeta}%},
    every node near coord/.style={xshift=rawx*1.5pt+0.5cm,text=white},
    ]
    addplot
    [Construction,fill=Construction]
    coordinates
    {(7.9,0) (8.8,1) (20.2,2) (28.7,3) (20.5,4) (44.7,5) (17.8,6) (46.6,7) (3.9,8)};
    addplot
    [Operational,fill=Operational,nodes near coords={}]
    coordinates
    {(89.7,0) (89.5,1) (76.3,2) (64.5,3) (76.3,4) (50.1,5) (70.5,6) (37.9,7) (95.4,8)};
    addplot
    [Maintenance,fill=Maintenance,nodes near coords={}]
    coordinates
    {(1.0,0) (1.5,1) (2.8,2) (6.4,3) (2.9,4) (4.8,5) (3.1,6)(15.3,7) (0.6,8)};
    addplot
    [Disposal,fill=Disposal,nodes near coords={}]
    coordinates
    {(1.3,0) (0.2,1) (0.7,2) (0.3,3) (0.3,4) (0.5,5) (8.6,6)(0.1,7) (0.1,8)};
    legend{Construction, Operational, Replacement, Disposal}
    end{axis}
    end{tikzpicture}
    caption{Life cycle phase contribution analysis per impact category.
    Categories
    from bottom to the top are Global Warming Potential (ac{GWP}), Ozone Depletion
    Potential (ac{ODP}), Photochemical Ozone Creation Potential (ac{POCP}),
    Acidification Potential (ac{AP}), Terrestrial Eutrophication Potential
    ac{EP(T)}, ac{EP(FW)}, ac{ADP} and ac{CED}.}
    label{conventional}
    end{figure}
    end{document}


    enter image description here






    share|improve this answer



























      up vote
      1
      down vote



      accepted










      It is somewhat hard to write an answer because this requires some fair amount of avoidable extra work. I ended up defining the missing colors somehow, and inventing a command ac. Now to your questions:




      1. You cannot see the xlabel since you put the legend on top. I moved the legend down.

      2. You can add numbers with percentages using nodes near coords. I made a guess which numbers you might be after, and of course this guess is most likely wrong, but perhaps will allow you to modify things in such a way that you get what you want.


      Result



      documentclass[10pt,twoside,a4paper,fleqn]{report}
      usepackage{xcolor,pgfplots}
      pgfplotsset{compat=1.16}
      definecolor{Construction}{RGB}{184,36,33}
      definecolor{Operational}{RGB}{233,171,100}
      definecolor{Maintenance}{RGB}{124,174,255}
      definecolor{Disposal}{RGB}{185,220,165}
      newcommand{ac}[1]{textcolor{red}{#1}}
      begin{document}
      begin{figure}[ht!]
      centering
      begin{tikzpicture}
      begin{axis}[clip=true,
      xbar stacked,
      legend style={
      legend columns=4,
      at={(xticklabel cs:0.5)},yshift=-5mm,
      anchor=north,
      draw=none
      },
      ytick=data,
      xtick=data,
      axis y line*=none,
      axis x line*=bottom,
      xlabel= Percentage,
      ylabel= Environmental indicators,
      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=.9textwidth,
      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},
      visualization depends on=x as rawx,
      nodes near coords={pgfmathprintnumber{pgfplotspointmeta}%},
      every node near coord/.style={xshift=rawx*1.5pt+0.5cm,text=white},
      ]
      addplot
      [Construction,fill=Construction]
      coordinates
      {(7.9,0) (8.8,1) (20.2,2) (28.7,3) (20.5,4) (44.7,5) (17.8,6) (46.6,7) (3.9,8)};
      addplot
      [Operational,fill=Operational,nodes near coords={}]
      coordinates
      {(89.7,0) (89.5,1) (76.3,2) (64.5,3) (76.3,4) (50.1,5) (70.5,6) (37.9,7) (95.4,8)};
      addplot
      [Maintenance,fill=Maintenance,nodes near coords={}]
      coordinates
      {(1.0,0) (1.5,1) (2.8,2) (6.4,3) (2.9,4) (4.8,5) (3.1,6)(15.3,7) (0.6,8)};
      addplot
      [Disposal,fill=Disposal,nodes near coords={}]
      coordinates
      {(1.3,0) (0.2,1) (0.7,2) (0.3,3) (0.3,4) (0.5,5) (8.6,6)(0.1,7) (0.1,8)};
      legend{Construction, Operational, Replacement, Disposal}
      end{axis}
      end{tikzpicture}
      caption{Life cycle phase contribution analysis per impact category.
      Categories
      from bottom to the top are Global Warming Potential (ac{GWP}), Ozone Depletion
      Potential (ac{ODP}), Photochemical Ozone Creation Potential (ac{POCP}),
      Acidification Potential (ac{AP}), Terrestrial Eutrophication Potential
      ac{EP(T)}, ac{EP(FW)}, ac{ADP} and ac{CED}.}
      label{conventional}
      end{figure}
      end{document}


      enter image description here






      share|improve this answer

























        up vote
        1
        down vote



        accepted







        up vote
        1
        down vote



        accepted






        It is somewhat hard to write an answer because this requires some fair amount of avoidable extra work. I ended up defining the missing colors somehow, and inventing a command ac. Now to your questions:




        1. You cannot see the xlabel since you put the legend on top. I moved the legend down.

        2. You can add numbers with percentages using nodes near coords. I made a guess which numbers you might be after, and of course this guess is most likely wrong, but perhaps will allow you to modify things in such a way that you get what you want.


        Result



        documentclass[10pt,twoside,a4paper,fleqn]{report}
        usepackage{xcolor,pgfplots}
        pgfplotsset{compat=1.16}
        definecolor{Construction}{RGB}{184,36,33}
        definecolor{Operational}{RGB}{233,171,100}
        definecolor{Maintenance}{RGB}{124,174,255}
        definecolor{Disposal}{RGB}{185,220,165}
        newcommand{ac}[1]{textcolor{red}{#1}}
        begin{document}
        begin{figure}[ht!]
        centering
        begin{tikzpicture}
        begin{axis}[clip=true,
        xbar stacked,
        legend style={
        legend columns=4,
        at={(xticklabel cs:0.5)},yshift=-5mm,
        anchor=north,
        draw=none
        },
        ytick=data,
        xtick=data,
        axis y line*=none,
        axis x line*=bottom,
        xlabel= Percentage,
        ylabel= Environmental indicators,
        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=.9textwidth,
        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},
        visualization depends on=x as rawx,
        nodes near coords={pgfmathprintnumber{pgfplotspointmeta}%},
        every node near coord/.style={xshift=rawx*1.5pt+0.5cm,text=white},
        ]
        addplot
        [Construction,fill=Construction]
        coordinates
        {(7.9,0) (8.8,1) (20.2,2) (28.7,3) (20.5,4) (44.7,5) (17.8,6) (46.6,7) (3.9,8)};
        addplot
        [Operational,fill=Operational,nodes near coords={}]
        coordinates
        {(89.7,0) (89.5,1) (76.3,2) (64.5,3) (76.3,4) (50.1,5) (70.5,6) (37.9,7) (95.4,8)};
        addplot
        [Maintenance,fill=Maintenance,nodes near coords={}]
        coordinates
        {(1.0,0) (1.5,1) (2.8,2) (6.4,3) (2.9,4) (4.8,5) (3.1,6)(15.3,7) (0.6,8)};
        addplot
        [Disposal,fill=Disposal,nodes near coords={}]
        coordinates
        {(1.3,0) (0.2,1) (0.7,2) (0.3,3) (0.3,4) (0.5,5) (8.6,6)(0.1,7) (0.1,8)};
        legend{Construction, Operational, Replacement, Disposal}
        end{axis}
        end{tikzpicture}
        caption{Life cycle phase contribution analysis per impact category.
        Categories
        from bottom to the top are Global Warming Potential (ac{GWP}), Ozone Depletion
        Potential (ac{ODP}), Photochemical Ozone Creation Potential (ac{POCP}),
        Acidification Potential (ac{AP}), Terrestrial Eutrophication Potential
        ac{EP(T)}, ac{EP(FW)}, ac{ADP} and ac{CED}.}
        label{conventional}
        end{figure}
        end{document}


        enter image description here






        share|improve this answer














        It is somewhat hard to write an answer because this requires some fair amount of avoidable extra work. I ended up defining the missing colors somehow, and inventing a command ac. Now to your questions:




        1. You cannot see the xlabel since you put the legend on top. I moved the legend down.

        2. You can add numbers with percentages using nodes near coords. I made a guess which numbers you might be after, and of course this guess is most likely wrong, but perhaps will allow you to modify things in such a way that you get what you want.


        Result



        documentclass[10pt,twoside,a4paper,fleqn]{report}
        usepackage{xcolor,pgfplots}
        pgfplotsset{compat=1.16}
        definecolor{Construction}{RGB}{184,36,33}
        definecolor{Operational}{RGB}{233,171,100}
        definecolor{Maintenance}{RGB}{124,174,255}
        definecolor{Disposal}{RGB}{185,220,165}
        newcommand{ac}[1]{textcolor{red}{#1}}
        begin{document}
        begin{figure}[ht!]
        centering
        begin{tikzpicture}
        begin{axis}[clip=true,
        xbar stacked,
        legend style={
        legend columns=4,
        at={(xticklabel cs:0.5)},yshift=-5mm,
        anchor=north,
        draw=none
        },
        ytick=data,
        xtick=data,
        axis y line*=none,
        axis x line*=bottom,
        xlabel= Percentage,
        ylabel= Environmental indicators,
        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=.9textwidth,
        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},
        visualization depends on=x as rawx,
        nodes near coords={pgfmathprintnumber{pgfplotspointmeta}%},
        every node near coord/.style={xshift=rawx*1.5pt+0.5cm,text=white},
        ]
        addplot
        [Construction,fill=Construction]
        coordinates
        {(7.9,0) (8.8,1) (20.2,2) (28.7,3) (20.5,4) (44.7,5) (17.8,6) (46.6,7) (3.9,8)};
        addplot
        [Operational,fill=Operational,nodes near coords={}]
        coordinates
        {(89.7,0) (89.5,1) (76.3,2) (64.5,3) (76.3,4) (50.1,5) (70.5,6) (37.9,7) (95.4,8)};
        addplot
        [Maintenance,fill=Maintenance,nodes near coords={}]
        coordinates
        {(1.0,0) (1.5,1) (2.8,2) (6.4,3) (2.9,4) (4.8,5) (3.1,6)(15.3,7) (0.6,8)};
        addplot
        [Disposal,fill=Disposal,nodes near coords={}]
        coordinates
        {(1.3,0) (0.2,1) (0.7,2) (0.3,3) (0.3,4) (0.5,5) (8.6,6)(0.1,7) (0.1,8)};
        legend{Construction, Operational, Replacement, Disposal}
        end{axis}
        end{tikzpicture}
        caption{Life cycle phase contribution analysis per impact category.
        Categories
        from bottom to the top are Global Warming Potential (ac{GWP}), Ozone Depletion
        Potential (ac{ODP}), Photochemical Ozone Creation Potential (ac{POCP}),
        Acidification Potential (ac{AP}), Terrestrial Eutrophication Potential
        ac{EP(T)}, ac{EP(FW)}, ac{ADP} and ac{CED}.}
        label{conventional}
        end{figure}
        end{document}


        enter image description here







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Nov 21 at 2:26

























        answered Nov 21 at 0:43









        marmot

        78.3k487166




        78.3k487166






























             

            draft saved


            draft discarded



















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f461009%2faxis-label-is-not-displayed-and-adding-labels-to-stacked-bar-chart%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            How to change which sound is reproduced for terminal bell?

            Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents

            Can I use Tabulator js library in my java Spring + Thymeleaf project?