Problem in bar plot, separating each set of data












2















I want to use a bar plot to compare some data. When I typed my code the results were not what I wanted. I want each set of bars to be separated clearly. The second point I want is the numbers are shown as I typed but int output the numbers were rounded. How can I solve these problems?



Here is my code



documentclass{standalone}

usepackage{amsmath}
usepackage{amsfonts}
usepackage{amssymb}
usepackage{pgfplots}
pgfplotsset{compat=newest}
usepackage{tikz}

begin{document}
begin{tikzpicture}
begin{axis}[
ybar=.5cm,
x tick label style={rotate=90},
enlarge x limits=0.2,
legend style={at={(0.5,-0.15)},
anchor=north,legend columns=-1},
bar width = 0.2 cm,
symbolic x coords= {4g,6g,8g,10g,2gamma,3gamma,4gamma,5gamma,6gamma,7gamma,0beta},
xtick=data,
xticklabels={$ 4_g $, $ 6_g $, $ 8_g $, $ 10_g $, $ 2_gamma $, $ 3_gamma $, $ 4_gamma $, $ 5_gamma $, $ 6_gamma $, $ 7_gamma $, $ 0_beta $},
nodes near coords,
nodes near coords align={vertical},
]
addplot coordinates {(4g, 2.337) (6g, 3.949) (8g, 5.815) (10g, 7.924) (2gamma, 1.830) (3gamma, 2.581) (4gamma, 4.379) (5gamma, 4.590) (6gamma, 6.983) (7gamma, 6.792) (0beta, 3.790)};

addplot coordinates {(4g, 2.479) (6g, 4.314) (8g, 6.377) (10g, 8.624) (2gamma, 1.935) (3gamma, 2.91) (4gamma, 3.795) (5gamma, 4.682) (6gamma, 5.905) (7gamma, 6.677) (0beta, 3.776)};

addplot coordinates {(4g, 2.350) (6g, 3.984) (8g, 5.877 ) (10g, 8.019) (2gamma, 1.837) (3gamma, 2.597) (4gamma, 4.420) (5gamma, 4.634) (6gamma, 7.063) (7gamma, 6.869) (0beta, 3.913)};

legend{used,understood,not understood}
end{axis}
end{tikzpicture}
end{document}


Many thanks.










share|improve this question





























    2















    I want to use a bar plot to compare some data. When I typed my code the results were not what I wanted. I want each set of bars to be separated clearly. The second point I want is the numbers are shown as I typed but int output the numbers were rounded. How can I solve these problems?



    Here is my code



    documentclass{standalone}

    usepackage{amsmath}
    usepackage{amsfonts}
    usepackage{amssymb}
    usepackage{pgfplots}
    pgfplotsset{compat=newest}
    usepackage{tikz}

    begin{document}
    begin{tikzpicture}
    begin{axis}[
    ybar=.5cm,
    x tick label style={rotate=90},
    enlarge x limits=0.2,
    legend style={at={(0.5,-0.15)},
    anchor=north,legend columns=-1},
    bar width = 0.2 cm,
    symbolic x coords= {4g,6g,8g,10g,2gamma,3gamma,4gamma,5gamma,6gamma,7gamma,0beta},
    xtick=data,
    xticklabels={$ 4_g $, $ 6_g $, $ 8_g $, $ 10_g $, $ 2_gamma $, $ 3_gamma $, $ 4_gamma $, $ 5_gamma $, $ 6_gamma $, $ 7_gamma $, $ 0_beta $},
    nodes near coords,
    nodes near coords align={vertical},
    ]
    addplot coordinates {(4g, 2.337) (6g, 3.949) (8g, 5.815) (10g, 7.924) (2gamma, 1.830) (3gamma, 2.581) (4gamma, 4.379) (5gamma, 4.590) (6gamma, 6.983) (7gamma, 6.792) (0beta, 3.790)};

    addplot coordinates {(4g, 2.479) (6g, 4.314) (8g, 6.377) (10g, 8.624) (2gamma, 1.935) (3gamma, 2.91) (4gamma, 3.795) (5gamma, 4.682) (6gamma, 5.905) (7gamma, 6.677) (0beta, 3.776)};

    addplot coordinates {(4g, 2.350) (6g, 3.984) (8g, 5.877 ) (10g, 8.019) (2gamma, 1.837) (3gamma, 2.597) (4gamma, 4.420) (5gamma, 4.634) (6gamma, 7.063) (7gamma, 6.869) (0beta, 3.913)};

    legend{used,understood,not understood}
    end{axis}
    end{tikzpicture}
    end{document}


    Many thanks.










    share|improve this question



























      2












      2








      2


      1






      I want to use a bar plot to compare some data. When I typed my code the results were not what I wanted. I want each set of bars to be separated clearly. The second point I want is the numbers are shown as I typed but int output the numbers were rounded. How can I solve these problems?



      Here is my code



      documentclass{standalone}

      usepackage{amsmath}
      usepackage{amsfonts}
      usepackage{amssymb}
      usepackage{pgfplots}
      pgfplotsset{compat=newest}
      usepackage{tikz}

      begin{document}
      begin{tikzpicture}
      begin{axis}[
      ybar=.5cm,
      x tick label style={rotate=90},
      enlarge x limits=0.2,
      legend style={at={(0.5,-0.15)},
      anchor=north,legend columns=-1},
      bar width = 0.2 cm,
      symbolic x coords= {4g,6g,8g,10g,2gamma,3gamma,4gamma,5gamma,6gamma,7gamma,0beta},
      xtick=data,
      xticklabels={$ 4_g $, $ 6_g $, $ 8_g $, $ 10_g $, $ 2_gamma $, $ 3_gamma $, $ 4_gamma $, $ 5_gamma $, $ 6_gamma $, $ 7_gamma $, $ 0_beta $},
      nodes near coords,
      nodes near coords align={vertical},
      ]
      addplot coordinates {(4g, 2.337) (6g, 3.949) (8g, 5.815) (10g, 7.924) (2gamma, 1.830) (3gamma, 2.581) (4gamma, 4.379) (5gamma, 4.590) (6gamma, 6.983) (7gamma, 6.792) (0beta, 3.790)};

      addplot coordinates {(4g, 2.479) (6g, 4.314) (8g, 6.377) (10g, 8.624) (2gamma, 1.935) (3gamma, 2.91) (4gamma, 3.795) (5gamma, 4.682) (6gamma, 5.905) (7gamma, 6.677) (0beta, 3.776)};

      addplot coordinates {(4g, 2.350) (6g, 3.984) (8g, 5.877 ) (10g, 8.019) (2gamma, 1.837) (3gamma, 2.597) (4gamma, 4.420) (5gamma, 4.634) (6gamma, 7.063) (7gamma, 6.869) (0beta, 3.913)};

      legend{used,understood,not understood}
      end{axis}
      end{tikzpicture}
      end{document}


      Many thanks.










      share|improve this question
















      I want to use a bar plot to compare some data. When I typed my code the results were not what I wanted. I want each set of bars to be separated clearly. The second point I want is the numbers are shown as I typed but int output the numbers were rounded. How can I solve these problems?



      Here is my code



      documentclass{standalone}

      usepackage{amsmath}
      usepackage{amsfonts}
      usepackage{amssymb}
      usepackage{pgfplots}
      pgfplotsset{compat=newest}
      usepackage{tikz}

      begin{document}
      begin{tikzpicture}
      begin{axis}[
      ybar=.5cm,
      x tick label style={rotate=90},
      enlarge x limits=0.2,
      legend style={at={(0.5,-0.15)},
      anchor=north,legend columns=-1},
      bar width = 0.2 cm,
      symbolic x coords= {4g,6g,8g,10g,2gamma,3gamma,4gamma,5gamma,6gamma,7gamma,0beta},
      xtick=data,
      xticklabels={$ 4_g $, $ 6_g $, $ 8_g $, $ 10_g $, $ 2_gamma $, $ 3_gamma $, $ 4_gamma $, $ 5_gamma $, $ 6_gamma $, $ 7_gamma $, $ 0_beta $},
      nodes near coords,
      nodes near coords align={vertical},
      ]
      addplot coordinates {(4g, 2.337) (6g, 3.949) (8g, 5.815) (10g, 7.924) (2gamma, 1.830) (3gamma, 2.581) (4gamma, 4.379) (5gamma, 4.590) (6gamma, 6.983) (7gamma, 6.792) (0beta, 3.790)};

      addplot coordinates {(4g, 2.479) (6g, 4.314) (8g, 6.377) (10g, 8.624) (2gamma, 1.935) (3gamma, 2.91) (4gamma, 3.795) (5gamma, 4.682) (6gamma, 5.905) (7gamma, 6.677) (0beta, 3.776)};

      addplot coordinates {(4g, 2.350) (6g, 3.984) (8g, 5.877 ) (10g, 8.019) (2gamma, 1.837) (3gamma, 2.597) (4gamma, 4.420) (5gamma, 4.634) (6gamma, 7.063) (7gamma, 6.869) (0beta, 3.913)};

      legend{used,understood,not understood}
      end{axis}
      end{tikzpicture}
      end{document}


      Many thanks.







      pgfplots






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 3 at 12:30









      Zarko

      127k868166




      127k868166










      asked Mar 3 at 6:26









      Hadi SobhaniHadi Sobhani

      27016




      27016






















          2 Answers
          2






          active

          oldest

          votes


















          1














          You have more data than a plot of that size can comfortably fit. In order to fit things, you may make the plot wider and also add the respective shifts. If you increase the precision, the rounding does not occur. In order to avoid the nodes to overlap that much, I rotated them.



          documentclass[tikz,border=3.14mm]{standalone}
          usepackage{pgfplots}
          pgfplotsset{compat=1.16,width=12cm}

          begin{document}
          begin{tikzpicture}
          begin{axis}[
          ybar=.8cm,
          x tick label style={rotate=90},
          %enlarge x limits=0.2,
          legend style={at={(0.5,-0.15)},
          anchor=north,legend columns=-1},
          bar width = 0.2 cm,
          symbolic x coords= {4g,6g,8g,10g,2gamma,3gamma,4gamma,5gamma,6gamma,7gamma,0beta},
          xtick=data,
          xticklabels={$ 4_g $, $ 6_g $, $ 8_g $, $ 10_g $, $ 2_gamma $, $ 3_gamma $, $ 4_gamma $, $ 5_gamma $, $ 6_gamma $, $ 7_gamma $, $ 0_beta $},
          nodes near coords={pgfmathprintnumber[precision=3]{pgfplotspointmeta}},
          nodes near coords align={vertical},
          nodes near coords style={rotate=90,anchor=west}
          ]
          addplot+[bar shift = -0.25cm] coordinates {(4g, 2.337) (6g, 3.949) (8g, 5.815) (10g, 7.924) (2gamma, 1.830) (3gamma, 2.581) (4gamma, 4.379) (5gamma, 4.590) (6gamma, 6.983) (7gamma, 6.792) (0beta, 3.790)};

          addplot+[bar shift = -0cm] coordinates {(4g, 2.479) (6g, 4.314) (8g, 6.377) (10g, 8.624) (2gamma, 1.935) (3gamma, 2.91) (4gamma, 3.795) (5gamma, 4.682) (6gamma, 5.905) (7gamma, 6.677) (0beta, 3.776)};

          addplot+[bar shift = 0.25cm] coordinates {(4g, 2.350) (6g, 3.984) (8g, 5.877 ) (10g, 8.019) (2gamma, 1.837) (3gamma, 2.597) (4gamma, 4.420) (5gamma, 4.634) (6gamma, 7.063) (7gamma, 6.869) (0beta, 3.913)};

          legend{used,understood,not understood}
          end{axis}
          end{tikzpicture}
          end{document}


          enter image description here






          share|improve this answer



















          • 1





            Dear @marmot, thank you so much:).

            – Hadi Sobhani
            Mar 3 at 6:58



















          1














          an alternative with use of pgfplotstable (for exercise ...)



          documentclass[margin=3mm]{standalone}
          usepackage{pgfplotstable}
          pgfplotsset{compat=1.16}

          begin{document}
          begin{tikzpicture}
          pgfplotstableread{% table with diagram's data
          X Y1 Y2 Y3
          $4_g$ 2.337 2.479 2.350
          $6_g$ 3.949 4.314 3.984
          $8_g$ 5.815 6.377 5.877
          $10_g$ 7.924 8.624 8.019
          $2_gamma$ 1.830 1.935 1.837
          $3_gamma$ 2.581 2.91 2.597
          $4_gamma$ 4.379 3.795 4.420
          $5_gamma$ 4.590 4.682 4.634
          $6_gamma$ 6.983 5.905 7.063
          $7_gamma$ 6.792 6.677 6.869
          $0_beta$ 3.790 3.776 3.913
          }mydata

          begin{axis}[width=99mm,
          ylabel=Population,
          legend style={legend columns=-1,
          font=footnotesize,
          /tikz/every even column/.append style={column sep=2mm},
          anchor=north,
          at={(0.5,-0.1)},
          },
          ybar=0.5mm, % distance between bars (shift bar)
          bar width=2mm, % width of bars
          nodes near coords={pgfmathprintnumber[precision=3]{pgfplotspointmeta}},
          nodes near coords style={font=scriptsize, rotate=90, anchor=west},
          nodes near coords align={vertical},
          ymin=0, ymax=10,
          ytick={0,...,10},
          %
          xtick=data,
          xticklabels from table = {mydata}{X},
          scale only axis,
          ]
          addplot table[x expr=coordindex,y index=1] {mydata};
          addplot table[x expr=coordindex,y index=2] {mydata};
          addplot table[x expr=coordindex,y index=3] {mydata};

          legend{used,understood,not understood}
          end{axis}
          end{tikzpicture}
          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',
            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%2f477509%2fproblem-in-bar-plot-separating-each-set-of-data%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            1














            You have more data than a plot of that size can comfortably fit. In order to fit things, you may make the plot wider and also add the respective shifts. If you increase the precision, the rounding does not occur. In order to avoid the nodes to overlap that much, I rotated them.



            documentclass[tikz,border=3.14mm]{standalone}
            usepackage{pgfplots}
            pgfplotsset{compat=1.16,width=12cm}

            begin{document}
            begin{tikzpicture}
            begin{axis}[
            ybar=.8cm,
            x tick label style={rotate=90},
            %enlarge x limits=0.2,
            legend style={at={(0.5,-0.15)},
            anchor=north,legend columns=-1},
            bar width = 0.2 cm,
            symbolic x coords= {4g,6g,8g,10g,2gamma,3gamma,4gamma,5gamma,6gamma,7gamma,0beta},
            xtick=data,
            xticklabels={$ 4_g $, $ 6_g $, $ 8_g $, $ 10_g $, $ 2_gamma $, $ 3_gamma $, $ 4_gamma $, $ 5_gamma $, $ 6_gamma $, $ 7_gamma $, $ 0_beta $},
            nodes near coords={pgfmathprintnumber[precision=3]{pgfplotspointmeta}},
            nodes near coords align={vertical},
            nodes near coords style={rotate=90,anchor=west}
            ]
            addplot+[bar shift = -0.25cm] coordinates {(4g, 2.337) (6g, 3.949) (8g, 5.815) (10g, 7.924) (2gamma, 1.830) (3gamma, 2.581) (4gamma, 4.379) (5gamma, 4.590) (6gamma, 6.983) (7gamma, 6.792) (0beta, 3.790)};

            addplot+[bar shift = -0cm] coordinates {(4g, 2.479) (6g, 4.314) (8g, 6.377) (10g, 8.624) (2gamma, 1.935) (3gamma, 2.91) (4gamma, 3.795) (5gamma, 4.682) (6gamma, 5.905) (7gamma, 6.677) (0beta, 3.776)};

            addplot+[bar shift = 0.25cm] coordinates {(4g, 2.350) (6g, 3.984) (8g, 5.877 ) (10g, 8.019) (2gamma, 1.837) (3gamma, 2.597) (4gamma, 4.420) (5gamma, 4.634) (6gamma, 7.063) (7gamma, 6.869) (0beta, 3.913)};

            legend{used,understood,not understood}
            end{axis}
            end{tikzpicture}
            end{document}


            enter image description here






            share|improve this answer



















            • 1





              Dear @marmot, thank you so much:).

              – Hadi Sobhani
              Mar 3 at 6:58
















            1














            You have more data than a plot of that size can comfortably fit. In order to fit things, you may make the plot wider and also add the respective shifts. If you increase the precision, the rounding does not occur. In order to avoid the nodes to overlap that much, I rotated them.



            documentclass[tikz,border=3.14mm]{standalone}
            usepackage{pgfplots}
            pgfplotsset{compat=1.16,width=12cm}

            begin{document}
            begin{tikzpicture}
            begin{axis}[
            ybar=.8cm,
            x tick label style={rotate=90},
            %enlarge x limits=0.2,
            legend style={at={(0.5,-0.15)},
            anchor=north,legend columns=-1},
            bar width = 0.2 cm,
            symbolic x coords= {4g,6g,8g,10g,2gamma,3gamma,4gamma,5gamma,6gamma,7gamma,0beta},
            xtick=data,
            xticklabels={$ 4_g $, $ 6_g $, $ 8_g $, $ 10_g $, $ 2_gamma $, $ 3_gamma $, $ 4_gamma $, $ 5_gamma $, $ 6_gamma $, $ 7_gamma $, $ 0_beta $},
            nodes near coords={pgfmathprintnumber[precision=3]{pgfplotspointmeta}},
            nodes near coords align={vertical},
            nodes near coords style={rotate=90,anchor=west}
            ]
            addplot+[bar shift = -0.25cm] coordinates {(4g, 2.337) (6g, 3.949) (8g, 5.815) (10g, 7.924) (2gamma, 1.830) (3gamma, 2.581) (4gamma, 4.379) (5gamma, 4.590) (6gamma, 6.983) (7gamma, 6.792) (0beta, 3.790)};

            addplot+[bar shift = -0cm] coordinates {(4g, 2.479) (6g, 4.314) (8g, 6.377) (10g, 8.624) (2gamma, 1.935) (3gamma, 2.91) (4gamma, 3.795) (5gamma, 4.682) (6gamma, 5.905) (7gamma, 6.677) (0beta, 3.776)};

            addplot+[bar shift = 0.25cm] coordinates {(4g, 2.350) (6g, 3.984) (8g, 5.877 ) (10g, 8.019) (2gamma, 1.837) (3gamma, 2.597) (4gamma, 4.420) (5gamma, 4.634) (6gamma, 7.063) (7gamma, 6.869) (0beta, 3.913)};

            legend{used,understood,not understood}
            end{axis}
            end{tikzpicture}
            end{document}


            enter image description here






            share|improve this answer



















            • 1





              Dear @marmot, thank you so much:).

              – Hadi Sobhani
              Mar 3 at 6:58














            1












            1








            1







            You have more data than a plot of that size can comfortably fit. In order to fit things, you may make the plot wider and also add the respective shifts. If you increase the precision, the rounding does not occur. In order to avoid the nodes to overlap that much, I rotated them.



            documentclass[tikz,border=3.14mm]{standalone}
            usepackage{pgfplots}
            pgfplotsset{compat=1.16,width=12cm}

            begin{document}
            begin{tikzpicture}
            begin{axis}[
            ybar=.8cm,
            x tick label style={rotate=90},
            %enlarge x limits=0.2,
            legend style={at={(0.5,-0.15)},
            anchor=north,legend columns=-1},
            bar width = 0.2 cm,
            symbolic x coords= {4g,6g,8g,10g,2gamma,3gamma,4gamma,5gamma,6gamma,7gamma,0beta},
            xtick=data,
            xticklabels={$ 4_g $, $ 6_g $, $ 8_g $, $ 10_g $, $ 2_gamma $, $ 3_gamma $, $ 4_gamma $, $ 5_gamma $, $ 6_gamma $, $ 7_gamma $, $ 0_beta $},
            nodes near coords={pgfmathprintnumber[precision=3]{pgfplotspointmeta}},
            nodes near coords align={vertical},
            nodes near coords style={rotate=90,anchor=west}
            ]
            addplot+[bar shift = -0.25cm] coordinates {(4g, 2.337) (6g, 3.949) (8g, 5.815) (10g, 7.924) (2gamma, 1.830) (3gamma, 2.581) (4gamma, 4.379) (5gamma, 4.590) (6gamma, 6.983) (7gamma, 6.792) (0beta, 3.790)};

            addplot+[bar shift = -0cm] coordinates {(4g, 2.479) (6g, 4.314) (8g, 6.377) (10g, 8.624) (2gamma, 1.935) (3gamma, 2.91) (4gamma, 3.795) (5gamma, 4.682) (6gamma, 5.905) (7gamma, 6.677) (0beta, 3.776)};

            addplot+[bar shift = 0.25cm] coordinates {(4g, 2.350) (6g, 3.984) (8g, 5.877 ) (10g, 8.019) (2gamma, 1.837) (3gamma, 2.597) (4gamma, 4.420) (5gamma, 4.634) (6gamma, 7.063) (7gamma, 6.869) (0beta, 3.913)};

            legend{used,understood,not understood}
            end{axis}
            end{tikzpicture}
            end{document}


            enter image description here






            share|improve this answer













            You have more data than a plot of that size can comfortably fit. In order to fit things, you may make the plot wider and also add the respective shifts. If you increase the precision, the rounding does not occur. In order to avoid the nodes to overlap that much, I rotated them.



            documentclass[tikz,border=3.14mm]{standalone}
            usepackage{pgfplots}
            pgfplotsset{compat=1.16,width=12cm}

            begin{document}
            begin{tikzpicture}
            begin{axis}[
            ybar=.8cm,
            x tick label style={rotate=90},
            %enlarge x limits=0.2,
            legend style={at={(0.5,-0.15)},
            anchor=north,legend columns=-1},
            bar width = 0.2 cm,
            symbolic x coords= {4g,6g,8g,10g,2gamma,3gamma,4gamma,5gamma,6gamma,7gamma,0beta},
            xtick=data,
            xticklabels={$ 4_g $, $ 6_g $, $ 8_g $, $ 10_g $, $ 2_gamma $, $ 3_gamma $, $ 4_gamma $, $ 5_gamma $, $ 6_gamma $, $ 7_gamma $, $ 0_beta $},
            nodes near coords={pgfmathprintnumber[precision=3]{pgfplotspointmeta}},
            nodes near coords align={vertical},
            nodes near coords style={rotate=90,anchor=west}
            ]
            addplot+[bar shift = -0.25cm] coordinates {(4g, 2.337) (6g, 3.949) (8g, 5.815) (10g, 7.924) (2gamma, 1.830) (3gamma, 2.581) (4gamma, 4.379) (5gamma, 4.590) (6gamma, 6.983) (7gamma, 6.792) (0beta, 3.790)};

            addplot+[bar shift = -0cm] coordinates {(4g, 2.479) (6g, 4.314) (8g, 6.377) (10g, 8.624) (2gamma, 1.935) (3gamma, 2.91) (4gamma, 3.795) (5gamma, 4.682) (6gamma, 5.905) (7gamma, 6.677) (0beta, 3.776)};

            addplot+[bar shift = 0.25cm] coordinates {(4g, 2.350) (6g, 3.984) (8g, 5.877 ) (10g, 8.019) (2gamma, 1.837) (3gamma, 2.597) (4gamma, 4.420) (5gamma, 4.634) (6gamma, 7.063) (7gamma, 6.869) (0beta, 3.913)};

            legend{used,understood,not understood}
            end{axis}
            end{tikzpicture}
            end{document}


            enter image description here







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Mar 3 at 6:51









            marmotmarmot

            107k5129244




            107k5129244








            • 1





              Dear @marmot, thank you so much:).

              – Hadi Sobhani
              Mar 3 at 6:58














            • 1





              Dear @marmot, thank you so much:).

              – Hadi Sobhani
              Mar 3 at 6:58








            1




            1





            Dear @marmot, thank you so much:).

            – Hadi Sobhani
            Mar 3 at 6:58





            Dear @marmot, thank you so much:).

            – Hadi Sobhani
            Mar 3 at 6:58











            1














            an alternative with use of pgfplotstable (for exercise ...)



            documentclass[margin=3mm]{standalone}
            usepackage{pgfplotstable}
            pgfplotsset{compat=1.16}

            begin{document}
            begin{tikzpicture}
            pgfplotstableread{% table with diagram's data
            X Y1 Y2 Y3
            $4_g$ 2.337 2.479 2.350
            $6_g$ 3.949 4.314 3.984
            $8_g$ 5.815 6.377 5.877
            $10_g$ 7.924 8.624 8.019
            $2_gamma$ 1.830 1.935 1.837
            $3_gamma$ 2.581 2.91 2.597
            $4_gamma$ 4.379 3.795 4.420
            $5_gamma$ 4.590 4.682 4.634
            $6_gamma$ 6.983 5.905 7.063
            $7_gamma$ 6.792 6.677 6.869
            $0_beta$ 3.790 3.776 3.913
            }mydata

            begin{axis}[width=99mm,
            ylabel=Population,
            legend style={legend columns=-1,
            font=footnotesize,
            /tikz/every even column/.append style={column sep=2mm},
            anchor=north,
            at={(0.5,-0.1)},
            },
            ybar=0.5mm, % distance between bars (shift bar)
            bar width=2mm, % width of bars
            nodes near coords={pgfmathprintnumber[precision=3]{pgfplotspointmeta}},
            nodes near coords style={font=scriptsize, rotate=90, anchor=west},
            nodes near coords align={vertical},
            ymin=0, ymax=10,
            ytick={0,...,10},
            %
            xtick=data,
            xticklabels from table = {mydata}{X},
            scale only axis,
            ]
            addplot table[x expr=coordindex,y index=1] {mydata};
            addplot table[x expr=coordindex,y index=2] {mydata};
            addplot table[x expr=coordindex,y index=3] {mydata};

            legend{used,understood,not understood}
            end{axis}
            end{tikzpicture}
            end{document}


            enter image description here






            share|improve this answer






























              1














              an alternative with use of pgfplotstable (for exercise ...)



              documentclass[margin=3mm]{standalone}
              usepackage{pgfplotstable}
              pgfplotsset{compat=1.16}

              begin{document}
              begin{tikzpicture}
              pgfplotstableread{% table with diagram's data
              X Y1 Y2 Y3
              $4_g$ 2.337 2.479 2.350
              $6_g$ 3.949 4.314 3.984
              $8_g$ 5.815 6.377 5.877
              $10_g$ 7.924 8.624 8.019
              $2_gamma$ 1.830 1.935 1.837
              $3_gamma$ 2.581 2.91 2.597
              $4_gamma$ 4.379 3.795 4.420
              $5_gamma$ 4.590 4.682 4.634
              $6_gamma$ 6.983 5.905 7.063
              $7_gamma$ 6.792 6.677 6.869
              $0_beta$ 3.790 3.776 3.913
              }mydata

              begin{axis}[width=99mm,
              ylabel=Population,
              legend style={legend columns=-1,
              font=footnotesize,
              /tikz/every even column/.append style={column sep=2mm},
              anchor=north,
              at={(0.5,-0.1)},
              },
              ybar=0.5mm, % distance between bars (shift bar)
              bar width=2mm, % width of bars
              nodes near coords={pgfmathprintnumber[precision=3]{pgfplotspointmeta}},
              nodes near coords style={font=scriptsize, rotate=90, anchor=west},
              nodes near coords align={vertical},
              ymin=0, ymax=10,
              ytick={0,...,10},
              %
              xtick=data,
              xticklabels from table = {mydata}{X},
              scale only axis,
              ]
              addplot table[x expr=coordindex,y index=1] {mydata};
              addplot table[x expr=coordindex,y index=2] {mydata};
              addplot table[x expr=coordindex,y index=3] {mydata};

              legend{used,understood,not understood}
              end{axis}
              end{tikzpicture}
              end{document}


              enter image description here






              share|improve this answer




























                1












                1








                1







                an alternative with use of pgfplotstable (for exercise ...)



                documentclass[margin=3mm]{standalone}
                usepackage{pgfplotstable}
                pgfplotsset{compat=1.16}

                begin{document}
                begin{tikzpicture}
                pgfplotstableread{% table with diagram's data
                X Y1 Y2 Y3
                $4_g$ 2.337 2.479 2.350
                $6_g$ 3.949 4.314 3.984
                $8_g$ 5.815 6.377 5.877
                $10_g$ 7.924 8.624 8.019
                $2_gamma$ 1.830 1.935 1.837
                $3_gamma$ 2.581 2.91 2.597
                $4_gamma$ 4.379 3.795 4.420
                $5_gamma$ 4.590 4.682 4.634
                $6_gamma$ 6.983 5.905 7.063
                $7_gamma$ 6.792 6.677 6.869
                $0_beta$ 3.790 3.776 3.913
                }mydata

                begin{axis}[width=99mm,
                ylabel=Population,
                legend style={legend columns=-1,
                font=footnotesize,
                /tikz/every even column/.append style={column sep=2mm},
                anchor=north,
                at={(0.5,-0.1)},
                },
                ybar=0.5mm, % distance between bars (shift bar)
                bar width=2mm, % width of bars
                nodes near coords={pgfmathprintnumber[precision=3]{pgfplotspointmeta}},
                nodes near coords style={font=scriptsize, rotate=90, anchor=west},
                nodes near coords align={vertical},
                ymin=0, ymax=10,
                ytick={0,...,10},
                %
                xtick=data,
                xticklabels from table = {mydata}{X},
                scale only axis,
                ]
                addplot table[x expr=coordindex,y index=1] {mydata};
                addplot table[x expr=coordindex,y index=2] {mydata};
                addplot table[x expr=coordindex,y index=3] {mydata};

                legend{used,understood,not understood}
                end{axis}
                end{tikzpicture}
                end{document}


                enter image description here






                share|improve this answer















                an alternative with use of pgfplotstable (for exercise ...)



                documentclass[margin=3mm]{standalone}
                usepackage{pgfplotstable}
                pgfplotsset{compat=1.16}

                begin{document}
                begin{tikzpicture}
                pgfplotstableread{% table with diagram's data
                X Y1 Y2 Y3
                $4_g$ 2.337 2.479 2.350
                $6_g$ 3.949 4.314 3.984
                $8_g$ 5.815 6.377 5.877
                $10_g$ 7.924 8.624 8.019
                $2_gamma$ 1.830 1.935 1.837
                $3_gamma$ 2.581 2.91 2.597
                $4_gamma$ 4.379 3.795 4.420
                $5_gamma$ 4.590 4.682 4.634
                $6_gamma$ 6.983 5.905 7.063
                $7_gamma$ 6.792 6.677 6.869
                $0_beta$ 3.790 3.776 3.913
                }mydata

                begin{axis}[width=99mm,
                ylabel=Population,
                legend style={legend columns=-1,
                font=footnotesize,
                /tikz/every even column/.append style={column sep=2mm},
                anchor=north,
                at={(0.5,-0.1)},
                },
                ybar=0.5mm, % distance between bars (shift bar)
                bar width=2mm, % width of bars
                nodes near coords={pgfmathprintnumber[precision=3]{pgfplotspointmeta}},
                nodes near coords style={font=scriptsize, rotate=90, anchor=west},
                nodes near coords align={vertical},
                ymin=0, ymax=10,
                ytick={0,...,10},
                %
                xtick=data,
                xticklabels from table = {mydata}{X},
                scale only axis,
                ]
                addplot table[x expr=coordindex,y index=1] {mydata};
                addplot table[x expr=coordindex,y index=2] {mydata};
                addplot table[x expr=coordindex,y index=3] {mydata};

                legend{used,understood,not understood}
                end{axis}
                end{tikzpicture}
                end{document}


                enter image description here







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Mar 3 at 13:08

























                answered Mar 3 at 8:40









                ZarkoZarko

                127k868166




                127k868166






























                    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.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f477509%2fproblem-in-bar-plot-separating-each-set-of-data%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?

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

                    Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents