Partial numbers in stacked bar plot











up vote
2
down vote

favorite












I have a problem with stacked bar in PGFplot. I would like to show the partial number of each segment, like this:



enter image description here



But instead of that, when I copy my code in TeXShop and compile it, I got the value of each segmen added up:



enter image description here



I used exactly the same code, as it is shown in the following URL:



http://pgfplots.net/tikz/examples/stacked-bar-plot/



Do you know what I need to change in order to have the desired representation?



Thanks a lot.










share|improve this question


























    up vote
    2
    down vote

    favorite












    I have a problem with stacked bar in PGFplot. I would like to show the partial number of each segment, like this:



    enter image description here



    But instead of that, when I copy my code in TeXShop and compile it, I got the value of each segmen added up:



    enter image description here



    I used exactly the same code, as it is shown in the following URL:



    http://pgfplots.net/tikz/examples/stacked-bar-plot/



    Do you know what I need to change in order to have the desired representation?



    Thanks a lot.










    share|improve this question
























      up vote
      2
      down vote

      favorite









      up vote
      2
      down vote

      favorite











      I have a problem with stacked bar in PGFplot. I would like to show the partial number of each segment, like this:



      enter image description here



      But instead of that, when I copy my code in TeXShop and compile it, I got the value of each segmen added up:



      enter image description here



      I used exactly the same code, as it is shown in the following URL:



      http://pgfplots.net/tikz/examples/stacked-bar-plot/



      Do you know what I need to change in order to have the desired representation?



      Thanks a lot.










      share|improve this question













      I have a problem with stacked bar in PGFplot. I would like to show the partial number of each segment, like this:



      enter image description here



      But instead of that, when I copy my code in TeXShop and compile it, I got the value of each segmen added up:



      enter image description here



      I used exactly the same code, as it is shown in the following URL:



      http://pgfplots.net/tikz/examples/stacked-bar-plot/



      Do you know what I need to change in order to have the desired representation?



      Thanks a lot.







      tikz-pgf pgfplots






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 30 at 10:18









      dedalus241

      134




      134






















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          2
          down vote



          accepted










          The documentation of pgfplots contains this (with special emphasis on the last paragraph):



          enter image description here



          So, as the comment in the beginning of the example code suggests, you have to change the compatibility set of pgfplots to 1.9, at least:



          documentclass[border=10pt]{standalone}
          usepackage{pgfplots}
          % pgfplotsset{width=7cm,compat=1.8}
          pgfplotsset{width=7cm,compat=1.9}% Changed here, only
          begin{document}
          begin{tikzpicture}
          begin{axis}[
          ybar stacked,
          bar width=15pt,
          nodes near coords,
          enlargelimits=0.15,
          legend style={at={(0.5,-0.20)},
          anchor=north,legend columns=-1},
          ylabel={#participants},
          symbolic x coords={tool1, tool2, tool3, tool4,
          tool5, tool6, tool7},
          xtick=data,
          x tick label style={rotate=45,anchor=east},
          ]
          addplot+[ybar] plot coordinates {(tool1,0) (tool2,2)
          (tool3,2) (tool4,3) (tool5,0) (tool6,2) (tool7,0)};
          addplot+[ybar] plot coordinates {(tool1,0) (tool2,0)
          (tool3,0) (tool4,3) (tool5,1) (tool6,1) (tool7,0)};
          addplot+[ybar] plot coordinates {(tool1,6) (tool2,6)
          (tool3,8) (tool4,2) (tool5,6) (tool6,5) (tool7,6)};
          addplot+[ybar] plot coordinates {(tool1,4) (tool2,2)
          (tool3,0) (tool4,2) (tool5,3) (tool6,2) (tool7,4)};
          legend{strut never, strut rarely, strut sometimes, strut often}
          end{axis}
          end{tikzpicture}
          end{document}


          and voilà:




          enter image description here







          share|improve this answer





















          • Thanks a lot for your help :-)
            – dedalus241
            Nov 30 at 12:35










          • @daedalus241 You're welcome :)
            – Phelype Oleinik
            Nov 30 at 12:40











          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%2f462540%2fpartial-numbers-in-stacked-bar-plot%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
          2
          down vote



          accepted










          The documentation of pgfplots contains this (with special emphasis on the last paragraph):



          enter image description here



          So, as the comment in the beginning of the example code suggests, you have to change the compatibility set of pgfplots to 1.9, at least:



          documentclass[border=10pt]{standalone}
          usepackage{pgfplots}
          % pgfplotsset{width=7cm,compat=1.8}
          pgfplotsset{width=7cm,compat=1.9}% Changed here, only
          begin{document}
          begin{tikzpicture}
          begin{axis}[
          ybar stacked,
          bar width=15pt,
          nodes near coords,
          enlargelimits=0.15,
          legend style={at={(0.5,-0.20)},
          anchor=north,legend columns=-1},
          ylabel={#participants},
          symbolic x coords={tool1, tool2, tool3, tool4,
          tool5, tool6, tool7},
          xtick=data,
          x tick label style={rotate=45,anchor=east},
          ]
          addplot+[ybar] plot coordinates {(tool1,0) (tool2,2)
          (tool3,2) (tool4,3) (tool5,0) (tool6,2) (tool7,0)};
          addplot+[ybar] plot coordinates {(tool1,0) (tool2,0)
          (tool3,0) (tool4,3) (tool5,1) (tool6,1) (tool7,0)};
          addplot+[ybar] plot coordinates {(tool1,6) (tool2,6)
          (tool3,8) (tool4,2) (tool5,6) (tool6,5) (tool7,6)};
          addplot+[ybar] plot coordinates {(tool1,4) (tool2,2)
          (tool3,0) (tool4,2) (tool5,3) (tool6,2) (tool7,4)};
          legend{strut never, strut rarely, strut sometimes, strut often}
          end{axis}
          end{tikzpicture}
          end{document}


          and voilà:




          enter image description here







          share|improve this answer





















          • Thanks a lot for your help :-)
            – dedalus241
            Nov 30 at 12:35










          • @daedalus241 You're welcome :)
            – Phelype Oleinik
            Nov 30 at 12:40















          up vote
          2
          down vote



          accepted










          The documentation of pgfplots contains this (with special emphasis on the last paragraph):



          enter image description here



          So, as the comment in the beginning of the example code suggests, you have to change the compatibility set of pgfplots to 1.9, at least:



          documentclass[border=10pt]{standalone}
          usepackage{pgfplots}
          % pgfplotsset{width=7cm,compat=1.8}
          pgfplotsset{width=7cm,compat=1.9}% Changed here, only
          begin{document}
          begin{tikzpicture}
          begin{axis}[
          ybar stacked,
          bar width=15pt,
          nodes near coords,
          enlargelimits=0.15,
          legend style={at={(0.5,-0.20)},
          anchor=north,legend columns=-1},
          ylabel={#participants},
          symbolic x coords={tool1, tool2, tool3, tool4,
          tool5, tool6, tool7},
          xtick=data,
          x tick label style={rotate=45,anchor=east},
          ]
          addplot+[ybar] plot coordinates {(tool1,0) (tool2,2)
          (tool3,2) (tool4,3) (tool5,0) (tool6,2) (tool7,0)};
          addplot+[ybar] plot coordinates {(tool1,0) (tool2,0)
          (tool3,0) (tool4,3) (tool5,1) (tool6,1) (tool7,0)};
          addplot+[ybar] plot coordinates {(tool1,6) (tool2,6)
          (tool3,8) (tool4,2) (tool5,6) (tool6,5) (tool7,6)};
          addplot+[ybar] plot coordinates {(tool1,4) (tool2,2)
          (tool3,0) (tool4,2) (tool5,3) (tool6,2) (tool7,4)};
          legend{strut never, strut rarely, strut sometimes, strut often}
          end{axis}
          end{tikzpicture}
          end{document}


          and voilà:




          enter image description here







          share|improve this answer





















          • Thanks a lot for your help :-)
            – dedalus241
            Nov 30 at 12:35










          • @daedalus241 You're welcome :)
            – Phelype Oleinik
            Nov 30 at 12:40













          up vote
          2
          down vote



          accepted







          up vote
          2
          down vote



          accepted






          The documentation of pgfplots contains this (with special emphasis on the last paragraph):



          enter image description here



          So, as the comment in the beginning of the example code suggests, you have to change the compatibility set of pgfplots to 1.9, at least:



          documentclass[border=10pt]{standalone}
          usepackage{pgfplots}
          % pgfplotsset{width=7cm,compat=1.8}
          pgfplotsset{width=7cm,compat=1.9}% Changed here, only
          begin{document}
          begin{tikzpicture}
          begin{axis}[
          ybar stacked,
          bar width=15pt,
          nodes near coords,
          enlargelimits=0.15,
          legend style={at={(0.5,-0.20)},
          anchor=north,legend columns=-1},
          ylabel={#participants},
          symbolic x coords={tool1, tool2, tool3, tool4,
          tool5, tool6, tool7},
          xtick=data,
          x tick label style={rotate=45,anchor=east},
          ]
          addplot+[ybar] plot coordinates {(tool1,0) (tool2,2)
          (tool3,2) (tool4,3) (tool5,0) (tool6,2) (tool7,0)};
          addplot+[ybar] plot coordinates {(tool1,0) (tool2,0)
          (tool3,0) (tool4,3) (tool5,1) (tool6,1) (tool7,0)};
          addplot+[ybar] plot coordinates {(tool1,6) (tool2,6)
          (tool3,8) (tool4,2) (tool5,6) (tool6,5) (tool7,6)};
          addplot+[ybar] plot coordinates {(tool1,4) (tool2,2)
          (tool3,0) (tool4,2) (tool5,3) (tool6,2) (tool7,4)};
          legend{strut never, strut rarely, strut sometimes, strut often}
          end{axis}
          end{tikzpicture}
          end{document}


          and voilà:




          enter image description here







          share|improve this answer












          The documentation of pgfplots contains this (with special emphasis on the last paragraph):



          enter image description here



          So, as the comment in the beginning of the example code suggests, you have to change the compatibility set of pgfplots to 1.9, at least:



          documentclass[border=10pt]{standalone}
          usepackage{pgfplots}
          % pgfplotsset{width=7cm,compat=1.8}
          pgfplotsset{width=7cm,compat=1.9}% Changed here, only
          begin{document}
          begin{tikzpicture}
          begin{axis}[
          ybar stacked,
          bar width=15pt,
          nodes near coords,
          enlargelimits=0.15,
          legend style={at={(0.5,-0.20)},
          anchor=north,legend columns=-1},
          ylabel={#participants},
          symbolic x coords={tool1, tool2, tool3, tool4,
          tool5, tool6, tool7},
          xtick=data,
          x tick label style={rotate=45,anchor=east},
          ]
          addplot+[ybar] plot coordinates {(tool1,0) (tool2,2)
          (tool3,2) (tool4,3) (tool5,0) (tool6,2) (tool7,0)};
          addplot+[ybar] plot coordinates {(tool1,0) (tool2,0)
          (tool3,0) (tool4,3) (tool5,1) (tool6,1) (tool7,0)};
          addplot+[ybar] plot coordinates {(tool1,6) (tool2,6)
          (tool3,8) (tool4,2) (tool5,6) (tool6,5) (tool7,6)};
          addplot+[ybar] plot coordinates {(tool1,4) (tool2,2)
          (tool3,0) (tool4,2) (tool5,3) (tool6,2) (tool7,4)};
          legend{strut never, strut rarely, strut sometimes, strut often}
          end{axis}
          end{tikzpicture}
          end{document}


          and voilà:




          enter image description here








          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 30 at 10:36









          Phelype Oleinik

          21.2k54380




          21.2k54380












          • Thanks a lot for your help :-)
            – dedalus241
            Nov 30 at 12:35










          • @daedalus241 You're welcome :)
            – Phelype Oleinik
            Nov 30 at 12:40


















          • Thanks a lot for your help :-)
            – dedalus241
            Nov 30 at 12:35










          • @daedalus241 You're welcome :)
            – Phelype Oleinik
            Nov 30 at 12:40
















          Thanks a lot for your help :-)
          – dedalus241
          Nov 30 at 12:35




          Thanks a lot for your help :-)
          – dedalus241
          Nov 30 at 12:35












          @daedalus241 You're welcome :)
          – Phelype Oleinik
          Nov 30 at 12:40




          @daedalus241 You're welcome :)
          – Phelype Oleinik
          Nov 30 at 12:40


















          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%2f462540%2fpartial-numbers-in-stacked-bar-plot%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?