pgfmathprintnumber label of bar values exceeding axis values












3














I'm trying to only have the y-value exceeding the axis to be labelled and not the rest (as shown in the picture below). Is there any suggestion how this can be made?enter image description here



my MWE (thanks to @Jake):



    documentclass{scrbook}
usepackage{pgfplots}
pgfplotsset{compat=newest}
usetikzlibrary{decorations.pathmorphing}


definecolor{bblue}{HTML}{4F81BD}
definecolor{rred}{HTML}{C0504D}
definecolor{ggreen}{HTML}{9BBB59}
definecolor{ppurple}{HTML}{9F4C7C}

begin{document}
begin{figure}
centering
begin{tikzpicture}
begin{axis}[
width = 0.9*textwidth,
height = 8cm,
major x tick style = transparent,
ybar=2*pgflinewidth,
bar width=4pt,
ymin=0,
axis on top,
ymax=12,
ymajorgrids = true,
xtick = data,
xlabel = {Environmental indicators},
symbolic x coords={GWP, ODP, POCP, AP, EP(T), EP(FW), EP(M), ADP, CED},
restrict y to domain*=0:14, % Cut values off at 14
visualization depends on=rawyasrawy, % Save the unclipped values
after end axis/.code={ % Draw line indicating break
draw [ultra thick, white, decoration={snake, amplitude=1pt}, decorate] (rel axis cs:0,1.05) -- (rel axis cs:1,1.05);
},
nodes near coords={%
pgfmathprintnumber{rawy}% Print unclipped values
},
axis lines*=left,
clip=false
]
addplot[style={bblue,fill=bblue,mark=none}]
coordinates { (GWP, 1.0)
(ODP,1.0)
(POCP,1.0)
(AP,1.0)
(EP(T),1.0)
(EP(FW),1.0)
(EP(M),1.0)
(ADP,1.0)
(CED,1.0)};
addplot[style={rred,fill=rred,mark=none}]
coordinates {(GWP,0.11)
(ODP,4.28)
(POCP,0.28 )
(AP,0.67)
(EP(T),0.38)
(EP(FW),1.0)
(EP(M),0.55)
(ADP,4.20)
(CED,1.0)};
addplot[style={ggreen,fill=ggreen,mark=none}]
coordinates {(GWP,1.42)
(ODP,1.37)
(POCP,1.26)
(AP,6.50)
(EP(T),6.65)
(EP(FW),48.56)
(EP(M),2.97)
(ADP,2.25)
(CED,1.0)};
addplot[style={ppurple,fill=ppurple,mark=none}]
coordinates { (GWP,0.74)
(ODP,2.07)
(POCP,2.69)
(AP,7.10)
(EP(T),3.03)
(EP(FW),6.88)
(EP(M),3.04)
(ADP,2.53)
(CED,1.0)};
legend{Singapore,France,Germany,Spain}
end{axis}
end{tikzpicture}
caption{Comparison of electricity profiles per 1 kWh of electricity}
end{figure}
end{document}









share|improve this question
























  • Welcome to TeX.SX! Are you searching for tex.stackexchange.com/a/365826/95441?
    – Stefan Pinnow
    Dec 8 at 17:18










  • @StefanPinnow thanks for your reply, unfortunately not quite what i wanted. I still want the bar protruding out the axis and also the white line acting as a "break".
    – thesilencer
    Dec 8 at 20:41
















3














I'm trying to only have the y-value exceeding the axis to be labelled and not the rest (as shown in the picture below). Is there any suggestion how this can be made?enter image description here



my MWE (thanks to @Jake):



    documentclass{scrbook}
usepackage{pgfplots}
pgfplotsset{compat=newest}
usetikzlibrary{decorations.pathmorphing}


definecolor{bblue}{HTML}{4F81BD}
definecolor{rred}{HTML}{C0504D}
definecolor{ggreen}{HTML}{9BBB59}
definecolor{ppurple}{HTML}{9F4C7C}

begin{document}
begin{figure}
centering
begin{tikzpicture}
begin{axis}[
width = 0.9*textwidth,
height = 8cm,
major x tick style = transparent,
ybar=2*pgflinewidth,
bar width=4pt,
ymin=0,
axis on top,
ymax=12,
ymajorgrids = true,
xtick = data,
xlabel = {Environmental indicators},
symbolic x coords={GWP, ODP, POCP, AP, EP(T), EP(FW), EP(M), ADP, CED},
restrict y to domain*=0:14, % Cut values off at 14
visualization depends on=rawyasrawy, % Save the unclipped values
after end axis/.code={ % Draw line indicating break
draw [ultra thick, white, decoration={snake, amplitude=1pt}, decorate] (rel axis cs:0,1.05) -- (rel axis cs:1,1.05);
},
nodes near coords={%
pgfmathprintnumber{rawy}% Print unclipped values
},
axis lines*=left,
clip=false
]
addplot[style={bblue,fill=bblue,mark=none}]
coordinates { (GWP, 1.0)
(ODP,1.0)
(POCP,1.0)
(AP,1.0)
(EP(T),1.0)
(EP(FW),1.0)
(EP(M),1.0)
(ADP,1.0)
(CED,1.0)};
addplot[style={rred,fill=rred,mark=none}]
coordinates {(GWP,0.11)
(ODP,4.28)
(POCP,0.28 )
(AP,0.67)
(EP(T),0.38)
(EP(FW),1.0)
(EP(M),0.55)
(ADP,4.20)
(CED,1.0)};
addplot[style={ggreen,fill=ggreen,mark=none}]
coordinates {(GWP,1.42)
(ODP,1.37)
(POCP,1.26)
(AP,6.50)
(EP(T),6.65)
(EP(FW),48.56)
(EP(M),2.97)
(ADP,2.25)
(CED,1.0)};
addplot[style={ppurple,fill=ppurple,mark=none}]
coordinates { (GWP,0.74)
(ODP,2.07)
(POCP,2.69)
(AP,7.10)
(EP(T),3.03)
(EP(FW),6.88)
(EP(M),3.04)
(ADP,2.53)
(CED,1.0)};
legend{Singapore,France,Germany,Spain}
end{axis}
end{tikzpicture}
caption{Comparison of electricity profiles per 1 kWh of electricity}
end{figure}
end{document}









share|improve this question
























  • Welcome to TeX.SX! Are you searching for tex.stackexchange.com/a/365826/95441?
    – Stefan Pinnow
    Dec 8 at 17:18










  • @StefanPinnow thanks for your reply, unfortunately not quite what i wanted. I still want the bar protruding out the axis and also the white line acting as a "break".
    – thesilencer
    Dec 8 at 20:41














3












3








3







I'm trying to only have the y-value exceeding the axis to be labelled and not the rest (as shown in the picture below). Is there any suggestion how this can be made?enter image description here



my MWE (thanks to @Jake):



    documentclass{scrbook}
usepackage{pgfplots}
pgfplotsset{compat=newest}
usetikzlibrary{decorations.pathmorphing}


definecolor{bblue}{HTML}{4F81BD}
definecolor{rred}{HTML}{C0504D}
definecolor{ggreen}{HTML}{9BBB59}
definecolor{ppurple}{HTML}{9F4C7C}

begin{document}
begin{figure}
centering
begin{tikzpicture}
begin{axis}[
width = 0.9*textwidth,
height = 8cm,
major x tick style = transparent,
ybar=2*pgflinewidth,
bar width=4pt,
ymin=0,
axis on top,
ymax=12,
ymajorgrids = true,
xtick = data,
xlabel = {Environmental indicators},
symbolic x coords={GWP, ODP, POCP, AP, EP(T), EP(FW), EP(M), ADP, CED},
restrict y to domain*=0:14, % Cut values off at 14
visualization depends on=rawyasrawy, % Save the unclipped values
after end axis/.code={ % Draw line indicating break
draw [ultra thick, white, decoration={snake, amplitude=1pt}, decorate] (rel axis cs:0,1.05) -- (rel axis cs:1,1.05);
},
nodes near coords={%
pgfmathprintnumber{rawy}% Print unclipped values
},
axis lines*=left,
clip=false
]
addplot[style={bblue,fill=bblue,mark=none}]
coordinates { (GWP, 1.0)
(ODP,1.0)
(POCP,1.0)
(AP,1.0)
(EP(T),1.0)
(EP(FW),1.0)
(EP(M),1.0)
(ADP,1.0)
(CED,1.0)};
addplot[style={rred,fill=rred,mark=none}]
coordinates {(GWP,0.11)
(ODP,4.28)
(POCP,0.28 )
(AP,0.67)
(EP(T),0.38)
(EP(FW),1.0)
(EP(M),0.55)
(ADP,4.20)
(CED,1.0)};
addplot[style={ggreen,fill=ggreen,mark=none}]
coordinates {(GWP,1.42)
(ODP,1.37)
(POCP,1.26)
(AP,6.50)
(EP(T),6.65)
(EP(FW),48.56)
(EP(M),2.97)
(ADP,2.25)
(CED,1.0)};
addplot[style={ppurple,fill=ppurple,mark=none}]
coordinates { (GWP,0.74)
(ODP,2.07)
(POCP,2.69)
(AP,7.10)
(EP(T),3.03)
(EP(FW),6.88)
(EP(M),3.04)
(ADP,2.53)
(CED,1.0)};
legend{Singapore,France,Germany,Spain}
end{axis}
end{tikzpicture}
caption{Comparison of electricity profiles per 1 kWh of electricity}
end{figure}
end{document}









share|improve this question















I'm trying to only have the y-value exceeding the axis to be labelled and not the rest (as shown in the picture below). Is there any suggestion how this can be made?enter image description here



my MWE (thanks to @Jake):



    documentclass{scrbook}
usepackage{pgfplots}
pgfplotsset{compat=newest}
usetikzlibrary{decorations.pathmorphing}


definecolor{bblue}{HTML}{4F81BD}
definecolor{rred}{HTML}{C0504D}
definecolor{ggreen}{HTML}{9BBB59}
definecolor{ppurple}{HTML}{9F4C7C}

begin{document}
begin{figure}
centering
begin{tikzpicture}
begin{axis}[
width = 0.9*textwidth,
height = 8cm,
major x tick style = transparent,
ybar=2*pgflinewidth,
bar width=4pt,
ymin=0,
axis on top,
ymax=12,
ymajorgrids = true,
xtick = data,
xlabel = {Environmental indicators},
symbolic x coords={GWP, ODP, POCP, AP, EP(T), EP(FW), EP(M), ADP, CED},
restrict y to domain*=0:14, % Cut values off at 14
visualization depends on=rawyasrawy, % Save the unclipped values
after end axis/.code={ % Draw line indicating break
draw [ultra thick, white, decoration={snake, amplitude=1pt}, decorate] (rel axis cs:0,1.05) -- (rel axis cs:1,1.05);
},
nodes near coords={%
pgfmathprintnumber{rawy}% Print unclipped values
},
axis lines*=left,
clip=false
]
addplot[style={bblue,fill=bblue,mark=none}]
coordinates { (GWP, 1.0)
(ODP,1.0)
(POCP,1.0)
(AP,1.0)
(EP(T),1.0)
(EP(FW),1.0)
(EP(M),1.0)
(ADP,1.0)
(CED,1.0)};
addplot[style={rred,fill=rred,mark=none}]
coordinates {(GWP,0.11)
(ODP,4.28)
(POCP,0.28 )
(AP,0.67)
(EP(T),0.38)
(EP(FW),1.0)
(EP(M),0.55)
(ADP,4.20)
(CED,1.0)};
addplot[style={ggreen,fill=ggreen,mark=none}]
coordinates {(GWP,1.42)
(ODP,1.37)
(POCP,1.26)
(AP,6.50)
(EP(T),6.65)
(EP(FW),48.56)
(EP(M),2.97)
(ADP,2.25)
(CED,1.0)};
addplot[style={ppurple,fill=ppurple,mark=none}]
coordinates { (GWP,0.74)
(ODP,2.07)
(POCP,2.69)
(AP,7.10)
(EP(T),3.03)
(EP(FW),6.88)
(EP(M),3.04)
(ADP,2.53)
(CED,1.0)};
legend{Singapore,France,Germany,Spain}
end{axis}
end{tikzpicture}
caption{Comparison of electricity profiles per 1 kWh of electricity}
end{figure}
end{document}






pgfplots labels bar-chart pgfmath






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 8 at 12:11

























asked Dec 8 at 11:59









thesilencer

1377




1377












  • Welcome to TeX.SX! Are you searching for tex.stackexchange.com/a/365826/95441?
    – Stefan Pinnow
    Dec 8 at 17:18










  • @StefanPinnow thanks for your reply, unfortunately not quite what i wanted. I still want the bar protruding out the axis and also the white line acting as a "break".
    – thesilencer
    Dec 8 at 20:41


















  • Welcome to TeX.SX! Are you searching for tex.stackexchange.com/a/365826/95441?
    – Stefan Pinnow
    Dec 8 at 17:18










  • @StefanPinnow thanks for your reply, unfortunately not quite what i wanted. I still want the bar protruding out the axis and also the white line acting as a "break".
    – thesilencer
    Dec 8 at 20:41
















Welcome to TeX.SX! Are you searching for tex.stackexchange.com/a/365826/95441?
– Stefan Pinnow
Dec 8 at 17:18




Welcome to TeX.SX! Are you searching for tex.stackexchange.com/a/365826/95441?
– Stefan Pinnow
Dec 8 at 17:18












@StefanPinnow thanks for your reply, unfortunately not quite what i wanted. I still want the bar protruding out the axis and also the white line acting as a "break".
– thesilencer
Dec 8 at 20:41




@StefanPinnow thanks for your reply, unfortunately not quite what i wanted. I still want the bar protruding out the axis and also the white line acting as a "break".
– thesilencer
Dec 8 at 20:41










1 Answer
1






active

oldest

votes


















0














Two steps to get this. The first is that you need to remove nodes near coords and its value from the begin[axis] parameter list. (This removes all labels). Next, you need to add nodes near coords into the individual addplot with the green bars. Doing this, you are stuck with all the green bars having a title, which is obviously not exactly what you need.



However, there is a trick to only added nodes near coords value on the particular coordinate that you want. (You count coordinates starting from an index of 0). So, in this case, (EP(FW),48.56) is the sixth item but index 5. Take the value {pgfmathprintnumber{rawy}} from above and wrap it with ifnum...fi as this example shows:



documentclass{scrbook}
usepackage{pgfplots}
pgfplotsset{compat=newest}
usetikzlibrary{decorations.pathmorphing}


definecolor{bblue}{HTML}{4F81BD}
definecolor{rred}{HTML}{C0504D}
definecolor{ggreen}{HTML}{9BBB59}
definecolor{ppurple}{HTML}{9F4C7C}

begin{document}
begin{figure}
centering
begin{tikzpicture}
begin{axis}[
width = 0.9*textwidth,
height = 8cm,
major x tick style = transparent,
ybar=2*pgflinewidth,
bar width=4pt,
ymin=0,
axis on top,
ymax=12,
ymajorgrids = true,
xtick = data,
xlabel = {Environmental indicators},
symbolic x coords={GWP, ODP, POCP, AP, EP(T), EP(FW), EP(M), ADP, CED},
restrict y to domain*=0:14, % Cut values off at 14
visualization depends on=rawyasrawy, % Save the unclipped values
after end axis/.code={ % Draw line indicating break
draw [ultra thick, white, decoration={snake, amplitude=1pt}, decorate] (rel axis cs:0,1.05) -- (rel axis cs:1,1.05);
},
%nodes near coords={%
%pgfmathprintnumber{rawy}% Print unclipped values
%},%REMOVED THIS PART
axis lines*=left,
clip=false
]
addplot[style={bblue,fill=bblue,mark=none}]
coordinates {(GWP, 1.0)
(ODP,1.0)
(POCP,1.0)
(AP,1.0)
(EP(T),1.0)
(EP(FW),1.0)
(EP(M),1.0)
(ADP,1.0)
(CED,1.0)};
addplot[style={rred,fill=rred,mark=none}]
coordinates {(GWP,0.11)
(ODP,4.28)
(POCP,0.28 )
(AP,0.67)
(EP(T),0.38)
(EP(FW),1.0)
(EP(M),0.55)
(ADP,4.20)
(CED,1.0)};
addplot[style={ggreen,fill=ggreen,mark=none},nodes near coords={ifnumcoordindex=5{pgfmathprintnumber{rawy}}elsefi}]%UPDATED THIS WITH A CONDITIONAL
coordinates {(GWP,1.42)
(ODP,1.37)
(POCP,1.26)
(AP,6.50)
(EP(T),6.65)
(EP(FW),48.56)
(EP(M),2.97)
(ADP,2.25)
(CED,1.0)};
addplot[style={ppurple,fill=ppurple,mark=none}]
coordinates { (GWP,0.74)
(ODP,2.07)
(POCP,2.69)
(AP,7.10)
(EP(T),3.03)
(EP(FW),6.88)
(EP(M),3.04)
(ADP,2.53)
(CED,1.0)};
legend{Singapore,France,Germany,Spain}
end{axis}
end{tikzpicture}
caption{Comparison of electricity profiles per 1 kWh of electricity}
end{figure}
end{document}


Graph with only one bar having a label



EDIT:



In case you are interested, I was able to adapt this from a somewhat similar question.






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',
    autoActivateHeartbeat: false,
    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%2f463802%2fpgfmathprintnumber-label-of-bar-values-exceeding-axis-values%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









    0














    Two steps to get this. The first is that you need to remove nodes near coords and its value from the begin[axis] parameter list. (This removes all labels). Next, you need to add nodes near coords into the individual addplot with the green bars. Doing this, you are stuck with all the green bars having a title, which is obviously not exactly what you need.



    However, there is a trick to only added nodes near coords value on the particular coordinate that you want. (You count coordinates starting from an index of 0). So, in this case, (EP(FW),48.56) is the sixth item but index 5. Take the value {pgfmathprintnumber{rawy}} from above and wrap it with ifnum...fi as this example shows:



    documentclass{scrbook}
    usepackage{pgfplots}
    pgfplotsset{compat=newest}
    usetikzlibrary{decorations.pathmorphing}


    definecolor{bblue}{HTML}{4F81BD}
    definecolor{rred}{HTML}{C0504D}
    definecolor{ggreen}{HTML}{9BBB59}
    definecolor{ppurple}{HTML}{9F4C7C}

    begin{document}
    begin{figure}
    centering
    begin{tikzpicture}
    begin{axis}[
    width = 0.9*textwidth,
    height = 8cm,
    major x tick style = transparent,
    ybar=2*pgflinewidth,
    bar width=4pt,
    ymin=0,
    axis on top,
    ymax=12,
    ymajorgrids = true,
    xtick = data,
    xlabel = {Environmental indicators},
    symbolic x coords={GWP, ODP, POCP, AP, EP(T), EP(FW), EP(M), ADP, CED},
    restrict y to domain*=0:14, % Cut values off at 14
    visualization depends on=rawyasrawy, % Save the unclipped values
    after end axis/.code={ % Draw line indicating break
    draw [ultra thick, white, decoration={snake, amplitude=1pt}, decorate] (rel axis cs:0,1.05) -- (rel axis cs:1,1.05);
    },
    %nodes near coords={%
    %pgfmathprintnumber{rawy}% Print unclipped values
    %},%REMOVED THIS PART
    axis lines*=left,
    clip=false
    ]
    addplot[style={bblue,fill=bblue,mark=none}]
    coordinates {(GWP, 1.0)
    (ODP,1.0)
    (POCP,1.0)
    (AP,1.0)
    (EP(T),1.0)
    (EP(FW),1.0)
    (EP(M),1.0)
    (ADP,1.0)
    (CED,1.0)};
    addplot[style={rred,fill=rred,mark=none}]
    coordinates {(GWP,0.11)
    (ODP,4.28)
    (POCP,0.28 )
    (AP,0.67)
    (EP(T),0.38)
    (EP(FW),1.0)
    (EP(M),0.55)
    (ADP,4.20)
    (CED,1.0)};
    addplot[style={ggreen,fill=ggreen,mark=none},nodes near coords={ifnumcoordindex=5{pgfmathprintnumber{rawy}}elsefi}]%UPDATED THIS WITH A CONDITIONAL
    coordinates {(GWP,1.42)
    (ODP,1.37)
    (POCP,1.26)
    (AP,6.50)
    (EP(T),6.65)
    (EP(FW),48.56)
    (EP(M),2.97)
    (ADP,2.25)
    (CED,1.0)};
    addplot[style={ppurple,fill=ppurple,mark=none}]
    coordinates { (GWP,0.74)
    (ODP,2.07)
    (POCP,2.69)
    (AP,7.10)
    (EP(T),3.03)
    (EP(FW),6.88)
    (EP(M),3.04)
    (ADP,2.53)
    (CED,1.0)};
    legend{Singapore,France,Germany,Spain}
    end{axis}
    end{tikzpicture}
    caption{Comparison of electricity profiles per 1 kWh of electricity}
    end{figure}
    end{document}


    Graph with only one bar having a label



    EDIT:



    In case you are interested, I was able to adapt this from a somewhat similar question.






    share|improve this answer


























      0














      Two steps to get this. The first is that you need to remove nodes near coords and its value from the begin[axis] parameter list. (This removes all labels). Next, you need to add nodes near coords into the individual addplot with the green bars. Doing this, you are stuck with all the green bars having a title, which is obviously not exactly what you need.



      However, there is a trick to only added nodes near coords value on the particular coordinate that you want. (You count coordinates starting from an index of 0). So, in this case, (EP(FW),48.56) is the sixth item but index 5. Take the value {pgfmathprintnumber{rawy}} from above and wrap it with ifnum...fi as this example shows:



      documentclass{scrbook}
      usepackage{pgfplots}
      pgfplotsset{compat=newest}
      usetikzlibrary{decorations.pathmorphing}


      definecolor{bblue}{HTML}{4F81BD}
      definecolor{rred}{HTML}{C0504D}
      definecolor{ggreen}{HTML}{9BBB59}
      definecolor{ppurple}{HTML}{9F4C7C}

      begin{document}
      begin{figure}
      centering
      begin{tikzpicture}
      begin{axis}[
      width = 0.9*textwidth,
      height = 8cm,
      major x tick style = transparent,
      ybar=2*pgflinewidth,
      bar width=4pt,
      ymin=0,
      axis on top,
      ymax=12,
      ymajorgrids = true,
      xtick = data,
      xlabel = {Environmental indicators},
      symbolic x coords={GWP, ODP, POCP, AP, EP(T), EP(FW), EP(M), ADP, CED},
      restrict y to domain*=0:14, % Cut values off at 14
      visualization depends on=rawyasrawy, % Save the unclipped values
      after end axis/.code={ % Draw line indicating break
      draw [ultra thick, white, decoration={snake, amplitude=1pt}, decorate] (rel axis cs:0,1.05) -- (rel axis cs:1,1.05);
      },
      %nodes near coords={%
      %pgfmathprintnumber{rawy}% Print unclipped values
      %},%REMOVED THIS PART
      axis lines*=left,
      clip=false
      ]
      addplot[style={bblue,fill=bblue,mark=none}]
      coordinates {(GWP, 1.0)
      (ODP,1.0)
      (POCP,1.0)
      (AP,1.0)
      (EP(T),1.0)
      (EP(FW),1.0)
      (EP(M),1.0)
      (ADP,1.0)
      (CED,1.0)};
      addplot[style={rred,fill=rred,mark=none}]
      coordinates {(GWP,0.11)
      (ODP,4.28)
      (POCP,0.28 )
      (AP,0.67)
      (EP(T),0.38)
      (EP(FW),1.0)
      (EP(M),0.55)
      (ADP,4.20)
      (CED,1.0)};
      addplot[style={ggreen,fill=ggreen,mark=none},nodes near coords={ifnumcoordindex=5{pgfmathprintnumber{rawy}}elsefi}]%UPDATED THIS WITH A CONDITIONAL
      coordinates {(GWP,1.42)
      (ODP,1.37)
      (POCP,1.26)
      (AP,6.50)
      (EP(T),6.65)
      (EP(FW),48.56)
      (EP(M),2.97)
      (ADP,2.25)
      (CED,1.0)};
      addplot[style={ppurple,fill=ppurple,mark=none}]
      coordinates { (GWP,0.74)
      (ODP,2.07)
      (POCP,2.69)
      (AP,7.10)
      (EP(T),3.03)
      (EP(FW),6.88)
      (EP(M),3.04)
      (ADP,2.53)
      (CED,1.0)};
      legend{Singapore,France,Germany,Spain}
      end{axis}
      end{tikzpicture}
      caption{Comparison of electricity profiles per 1 kWh of electricity}
      end{figure}
      end{document}


      Graph with only one bar having a label



      EDIT:



      In case you are interested, I was able to adapt this from a somewhat similar question.






      share|improve this answer
























        0












        0








        0






        Two steps to get this. The first is that you need to remove nodes near coords and its value from the begin[axis] parameter list. (This removes all labels). Next, you need to add nodes near coords into the individual addplot with the green bars. Doing this, you are stuck with all the green bars having a title, which is obviously not exactly what you need.



        However, there is a trick to only added nodes near coords value on the particular coordinate that you want. (You count coordinates starting from an index of 0). So, in this case, (EP(FW),48.56) is the sixth item but index 5. Take the value {pgfmathprintnumber{rawy}} from above and wrap it with ifnum...fi as this example shows:



        documentclass{scrbook}
        usepackage{pgfplots}
        pgfplotsset{compat=newest}
        usetikzlibrary{decorations.pathmorphing}


        definecolor{bblue}{HTML}{4F81BD}
        definecolor{rred}{HTML}{C0504D}
        definecolor{ggreen}{HTML}{9BBB59}
        definecolor{ppurple}{HTML}{9F4C7C}

        begin{document}
        begin{figure}
        centering
        begin{tikzpicture}
        begin{axis}[
        width = 0.9*textwidth,
        height = 8cm,
        major x tick style = transparent,
        ybar=2*pgflinewidth,
        bar width=4pt,
        ymin=0,
        axis on top,
        ymax=12,
        ymajorgrids = true,
        xtick = data,
        xlabel = {Environmental indicators},
        symbolic x coords={GWP, ODP, POCP, AP, EP(T), EP(FW), EP(M), ADP, CED},
        restrict y to domain*=0:14, % Cut values off at 14
        visualization depends on=rawyasrawy, % Save the unclipped values
        after end axis/.code={ % Draw line indicating break
        draw [ultra thick, white, decoration={snake, amplitude=1pt}, decorate] (rel axis cs:0,1.05) -- (rel axis cs:1,1.05);
        },
        %nodes near coords={%
        %pgfmathprintnumber{rawy}% Print unclipped values
        %},%REMOVED THIS PART
        axis lines*=left,
        clip=false
        ]
        addplot[style={bblue,fill=bblue,mark=none}]
        coordinates {(GWP, 1.0)
        (ODP,1.0)
        (POCP,1.0)
        (AP,1.0)
        (EP(T),1.0)
        (EP(FW),1.0)
        (EP(M),1.0)
        (ADP,1.0)
        (CED,1.0)};
        addplot[style={rred,fill=rred,mark=none}]
        coordinates {(GWP,0.11)
        (ODP,4.28)
        (POCP,0.28 )
        (AP,0.67)
        (EP(T),0.38)
        (EP(FW),1.0)
        (EP(M),0.55)
        (ADP,4.20)
        (CED,1.0)};
        addplot[style={ggreen,fill=ggreen,mark=none},nodes near coords={ifnumcoordindex=5{pgfmathprintnumber{rawy}}elsefi}]%UPDATED THIS WITH A CONDITIONAL
        coordinates {(GWP,1.42)
        (ODP,1.37)
        (POCP,1.26)
        (AP,6.50)
        (EP(T),6.65)
        (EP(FW),48.56)
        (EP(M),2.97)
        (ADP,2.25)
        (CED,1.0)};
        addplot[style={ppurple,fill=ppurple,mark=none}]
        coordinates { (GWP,0.74)
        (ODP,2.07)
        (POCP,2.69)
        (AP,7.10)
        (EP(T),3.03)
        (EP(FW),6.88)
        (EP(M),3.04)
        (ADP,2.53)
        (CED,1.0)};
        legend{Singapore,France,Germany,Spain}
        end{axis}
        end{tikzpicture}
        caption{Comparison of electricity profiles per 1 kWh of electricity}
        end{figure}
        end{document}


        Graph with only one bar having a label



        EDIT:



        In case you are interested, I was able to adapt this from a somewhat similar question.






        share|improve this answer












        Two steps to get this. The first is that you need to remove nodes near coords and its value from the begin[axis] parameter list. (This removes all labels). Next, you need to add nodes near coords into the individual addplot with the green bars. Doing this, you are stuck with all the green bars having a title, which is obviously not exactly what you need.



        However, there is a trick to only added nodes near coords value on the particular coordinate that you want. (You count coordinates starting from an index of 0). So, in this case, (EP(FW),48.56) is the sixth item but index 5. Take the value {pgfmathprintnumber{rawy}} from above and wrap it with ifnum...fi as this example shows:



        documentclass{scrbook}
        usepackage{pgfplots}
        pgfplotsset{compat=newest}
        usetikzlibrary{decorations.pathmorphing}


        definecolor{bblue}{HTML}{4F81BD}
        definecolor{rred}{HTML}{C0504D}
        definecolor{ggreen}{HTML}{9BBB59}
        definecolor{ppurple}{HTML}{9F4C7C}

        begin{document}
        begin{figure}
        centering
        begin{tikzpicture}
        begin{axis}[
        width = 0.9*textwidth,
        height = 8cm,
        major x tick style = transparent,
        ybar=2*pgflinewidth,
        bar width=4pt,
        ymin=0,
        axis on top,
        ymax=12,
        ymajorgrids = true,
        xtick = data,
        xlabel = {Environmental indicators},
        symbolic x coords={GWP, ODP, POCP, AP, EP(T), EP(FW), EP(M), ADP, CED},
        restrict y to domain*=0:14, % Cut values off at 14
        visualization depends on=rawyasrawy, % Save the unclipped values
        after end axis/.code={ % Draw line indicating break
        draw [ultra thick, white, decoration={snake, amplitude=1pt}, decorate] (rel axis cs:0,1.05) -- (rel axis cs:1,1.05);
        },
        %nodes near coords={%
        %pgfmathprintnumber{rawy}% Print unclipped values
        %},%REMOVED THIS PART
        axis lines*=left,
        clip=false
        ]
        addplot[style={bblue,fill=bblue,mark=none}]
        coordinates {(GWP, 1.0)
        (ODP,1.0)
        (POCP,1.0)
        (AP,1.0)
        (EP(T),1.0)
        (EP(FW),1.0)
        (EP(M),1.0)
        (ADP,1.0)
        (CED,1.0)};
        addplot[style={rred,fill=rred,mark=none}]
        coordinates {(GWP,0.11)
        (ODP,4.28)
        (POCP,0.28 )
        (AP,0.67)
        (EP(T),0.38)
        (EP(FW),1.0)
        (EP(M),0.55)
        (ADP,4.20)
        (CED,1.0)};
        addplot[style={ggreen,fill=ggreen,mark=none},nodes near coords={ifnumcoordindex=5{pgfmathprintnumber{rawy}}elsefi}]%UPDATED THIS WITH A CONDITIONAL
        coordinates {(GWP,1.42)
        (ODP,1.37)
        (POCP,1.26)
        (AP,6.50)
        (EP(T),6.65)
        (EP(FW),48.56)
        (EP(M),2.97)
        (ADP,2.25)
        (CED,1.0)};
        addplot[style={ppurple,fill=ppurple,mark=none}]
        coordinates { (GWP,0.74)
        (ODP,2.07)
        (POCP,2.69)
        (AP,7.10)
        (EP(T),3.03)
        (EP(FW),6.88)
        (EP(M),3.04)
        (ADP,2.53)
        (CED,1.0)};
        legend{Singapore,France,Germany,Spain}
        end{axis}
        end{tikzpicture}
        caption{Comparison of electricity profiles per 1 kWh of electricity}
        end{figure}
        end{document}


        Graph with only one bar having a label



        EDIT:



        In case you are interested, I was able to adapt this from a somewhat similar question.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 10 hours ago









        whatisit

        852313




        852313






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f463802%2fpgfmathprintnumber-label-of-bar-values-exceeding-axis-values%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?