Tikz barchart space between bars within group












2















I have the following bar chart:



documentclass[tikz]{standalone}

usepackage{pgfplots}

begin{document}
begin{tikzpicture}
begin{axis}[
legend style={at={(1.2,1)},anchor=north},
ybar,
xticklabels={},
bar width=0.6cm,
width=5cm,
height=5cm,
grid=none,
ymin=0,
nodes near coords, style={xshift=0pt,yshift=0pt,anchor=north,font=footnotesize},
]

addplot plot coordinates {(1, 3.0)};
addplot plot coordinates {(1, 0.7)};
addplot plot coordinates {(1, 0.9)};

legend{A, B, C}
end{axis}
end{tikzpicture}
end{document}


enter image description here



My question is: How can I increase the space between the bars?










share|improve this question





























    2















    I have the following bar chart:



    documentclass[tikz]{standalone}

    usepackage{pgfplots}

    begin{document}
    begin{tikzpicture}
    begin{axis}[
    legend style={at={(1.2,1)},anchor=north},
    ybar,
    xticklabels={},
    bar width=0.6cm,
    width=5cm,
    height=5cm,
    grid=none,
    ymin=0,
    nodes near coords, style={xshift=0pt,yshift=0pt,anchor=north,font=footnotesize},
    ]

    addplot plot coordinates {(1, 3.0)};
    addplot plot coordinates {(1, 0.7)};
    addplot plot coordinates {(1, 0.9)};

    legend{A, B, C}
    end{axis}
    end{tikzpicture}
    end{document}


    enter image description here



    My question is: How can I increase the space between the bars?










    share|improve this question



























      2












      2








      2








      I have the following bar chart:



      documentclass[tikz]{standalone}

      usepackage{pgfplots}

      begin{document}
      begin{tikzpicture}
      begin{axis}[
      legend style={at={(1.2,1)},anchor=north},
      ybar,
      xticklabels={},
      bar width=0.6cm,
      width=5cm,
      height=5cm,
      grid=none,
      ymin=0,
      nodes near coords, style={xshift=0pt,yshift=0pt,anchor=north,font=footnotesize},
      ]

      addplot plot coordinates {(1, 3.0)};
      addplot plot coordinates {(1, 0.7)};
      addplot plot coordinates {(1, 0.9)};

      legend{A, B, C}
      end{axis}
      end{tikzpicture}
      end{document}


      enter image description here



      My question is: How can I increase the space between the bars?










      share|improve this question
















      I have the following bar chart:



      documentclass[tikz]{standalone}

      usepackage{pgfplots}

      begin{document}
      begin{tikzpicture}
      begin{axis}[
      legend style={at={(1.2,1)},anchor=north},
      ybar,
      xticklabels={},
      bar width=0.6cm,
      width=5cm,
      height=5cm,
      grid=none,
      ymin=0,
      nodes near coords, style={xshift=0pt,yshift=0pt,anchor=north,font=footnotesize},
      ]

      addplot plot coordinates {(1, 3.0)};
      addplot plot coordinates {(1, 0.7)};
      addplot plot coordinates {(1, 0.9)};

      legend{A, B, C}
      end{axis}
      end{tikzpicture}
      end{document}


      enter image description here



      My question is: How can I increase the space between the bars?







      tikz-pgf pgfplots






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 24 at 13:56









      JouleV

      10.3k22558




      10.3k22558










      asked Mar 24 at 9:45









      user184165user184165

      111




      111






















          1 Answer
          1






          active

          oldest

          votes


















          1














          So if you do not need any more sophisticated solution, the following should work:



          documentclass[tikz]{standalone}

          usepackage{pgfplots}

          begin{document}
          begin{tikzpicture}
          pgfplotsset{
          ytick style={draw=none},
          }
          begin{axis}[
          ybar=2pt, % change this of you have more than one bar per column
          x=0.9cm, % just play with the relation of these
          bar width=0.1cm, % just play with with the relation of these
          bar shift=0,
          height=5cm,
          width=5cm,
          grid=none,
          ymin=0,
          ymax=5,
          symbolic x coords={A,B,C},
          xmin=A,
          xmax=C,
          enlarge x limits=0.5,
          ytick pos=left,
          ytick={0,...,5},
          xtick pos=left,
          xtick={A,...,C},
          tick align=outside,
          nodes near coords,
          style={xshift=0pt,yshift=0pt,anchor=north,font=footnotesize},
          ]

          addplot coordinates {(A, 3.0)};
          addplot coordinates {(B, 0.7)};
          addplot coordinates {(C, 0.9)};

          end{axis}
          end{tikzpicture}
          end{document}


          Just play with x and bar widths, that should do for your plot.
          Still there are a lot of examples and forum entries already that would have given you an answer, so maybe next time try to google ;). Best Regards






          share|improve this answer


























          • Thank you very much for your answer. How would I get a legend as in my example above. That was the reason why I put all three bars in the same column, but then I could not adjust the space between them. Sorry for my newbie questions, but I googled a lot and unfortunately could not find a satisfying answer.

            – user184165
            Mar 24 at 17:04











          • You are welcome ;). For a legend just add "legend position = north east" and than legend{A, B, C} as you did in your example. And in your example you made three columns. For one column write addplot coordinates {(y1, x1), (y2, x2), (y3, x3)}. To change the space between then, adjust the ybar value. Regards

            – Markus_J.
            Mar 27 at 16:03












          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%2f481177%2ftikz-barchart-space-between-bars-within-group%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









          1














          So if you do not need any more sophisticated solution, the following should work:



          documentclass[tikz]{standalone}

          usepackage{pgfplots}

          begin{document}
          begin{tikzpicture}
          pgfplotsset{
          ytick style={draw=none},
          }
          begin{axis}[
          ybar=2pt, % change this of you have more than one bar per column
          x=0.9cm, % just play with the relation of these
          bar width=0.1cm, % just play with with the relation of these
          bar shift=0,
          height=5cm,
          width=5cm,
          grid=none,
          ymin=0,
          ymax=5,
          symbolic x coords={A,B,C},
          xmin=A,
          xmax=C,
          enlarge x limits=0.5,
          ytick pos=left,
          ytick={0,...,5},
          xtick pos=left,
          xtick={A,...,C},
          tick align=outside,
          nodes near coords,
          style={xshift=0pt,yshift=0pt,anchor=north,font=footnotesize},
          ]

          addplot coordinates {(A, 3.0)};
          addplot coordinates {(B, 0.7)};
          addplot coordinates {(C, 0.9)};

          end{axis}
          end{tikzpicture}
          end{document}


          Just play with x and bar widths, that should do for your plot.
          Still there are a lot of examples and forum entries already that would have given you an answer, so maybe next time try to google ;). Best Regards






          share|improve this answer


























          • Thank you very much for your answer. How would I get a legend as in my example above. That was the reason why I put all three bars in the same column, but then I could not adjust the space between them. Sorry for my newbie questions, but I googled a lot and unfortunately could not find a satisfying answer.

            – user184165
            Mar 24 at 17:04











          • You are welcome ;). For a legend just add "legend position = north east" and than legend{A, B, C} as you did in your example. And in your example you made three columns. For one column write addplot coordinates {(y1, x1), (y2, x2), (y3, x3)}. To change the space between then, adjust the ybar value. Regards

            – Markus_J.
            Mar 27 at 16:03
















          1














          So if you do not need any more sophisticated solution, the following should work:



          documentclass[tikz]{standalone}

          usepackage{pgfplots}

          begin{document}
          begin{tikzpicture}
          pgfplotsset{
          ytick style={draw=none},
          }
          begin{axis}[
          ybar=2pt, % change this of you have more than one bar per column
          x=0.9cm, % just play with the relation of these
          bar width=0.1cm, % just play with with the relation of these
          bar shift=0,
          height=5cm,
          width=5cm,
          grid=none,
          ymin=0,
          ymax=5,
          symbolic x coords={A,B,C},
          xmin=A,
          xmax=C,
          enlarge x limits=0.5,
          ytick pos=left,
          ytick={0,...,5},
          xtick pos=left,
          xtick={A,...,C},
          tick align=outside,
          nodes near coords,
          style={xshift=0pt,yshift=0pt,anchor=north,font=footnotesize},
          ]

          addplot coordinates {(A, 3.0)};
          addplot coordinates {(B, 0.7)};
          addplot coordinates {(C, 0.9)};

          end{axis}
          end{tikzpicture}
          end{document}


          Just play with x and bar widths, that should do for your plot.
          Still there are a lot of examples and forum entries already that would have given you an answer, so maybe next time try to google ;). Best Regards






          share|improve this answer


























          • Thank you very much for your answer. How would I get a legend as in my example above. That was the reason why I put all three bars in the same column, but then I could not adjust the space between them. Sorry for my newbie questions, but I googled a lot and unfortunately could not find a satisfying answer.

            – user184165
            Mar 24 at 17:04











          • You are welcome ;). For a legend just add "legend position = north east" and than legend{A, B, C} as you did in your example. And in your example you made three columns. For one column write addplot coordinates {(y1, x1), (y2, x2), (y3, x3)}. To change the space between then, adjust the ybar value. Regards

            – Markus_J.
            Mar 27 at 16:03














          1












          1








          1







          So if you do not need any more sophisticated solution, the following should work:



          documentclass[tikz]{standalone}

          usepackage{pgfplots}

          begin{document}
          begin{tikzpicture}
          pgfplotsset{
          ytick style={draw=none},
          }
          begin{axis}[
          ybar=2pt, % change this of you have more than one bar per column
          x=0.9cm, % just play with the relation of these
          bar width=0.1cm, % just play with with the relation of these
          bar shift=0,
          height=5cm,
          width=5cm,
          grid=none,
          ymin=0,
          ymax=5,
          symbolic x coords={A,B,C},
          xmin=A,
          xmax=C,
          enlarge x limits=0.5,
          ytick pos=left,
          ytick={0,...,5},
          xtick pos=left,
          xtick={A,...,C},
          tick align=outside,
          nodes near coords,
          style={xshift=0pt,yshift=0pt,anchor=north,font=footnotesize},
          ]

          addplot coordinates {(A, 3.0)};
          addplot coordinates {(B, 0.7)};
          addplot coordinates {(C, 0.9)};

          end{axis}
          end{tikzpicture}
          end{document}


          Just play with x and bar widths, that should do for your plot.
          Still there are a lot of examples and forum entries already that would have given you an answer, so maybe next time try to google ;). Best Regards






          share|improve this answer















          So if you do not need any more sophisticated solution, the following should work:



          documentclass[tikz]{standalone}

          usepackage{pgfplots}

          begin{document}
          begin{tikzpicture}
          pgfplotsset{
          ytick style={draw=none},
          }
          begin{axis}[
          ybar=2pt, % change this of you have more than one bar per column
          x=0.9cm, % just play with the relation of these
          bar width=0.1cm, % just play with with the relation of these
          bar shift=0,
          height=5cm,
          width=5cm,
          grid=none,
          ymin=0,
          ymax=5,
          symbolic x coords={A,B,C},
          xmin=A,
          xmax=C,
          enlarge x limits=0.5,
          ytick pos=left,
          ytick={0,...,5},
          xtick pos=left,
          xtick={A,...,C},
          tick align=outside,
          nodes near coords,
          style={xshift=0pt,yshift=0pt,anchor=north,font=footnotesize},
          ]

          addplot coordinates {(A, 3.0)};
          addplot coordinates {(B, 0.7)};
          addplot coordinates {(C, 0.9)};

          end{axis}
          end{tikzpicture}
          end{document}


          Just play with x and bar widths, that should do for your plot.
          Still there are a lot of examples and forum entries already that would have given you an answer, so maybe next time try to google ;). Best Regards







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Mar 24 at 15:07

























          answered Mar 24 at 12:01









          Markus_J.Markus_J.

          286




          286













          • Thank you very much for your answer. How would I get a legend as in my example above. That was the reason why I put all three bars in the same column, but then I could not adjust the space between them. Sorry for my newbie questions, but I googled a lot and unfortunately could not find a satisfying answer.

            – user184165
            Mar 24 at 17:04











          • You are welcome ;). For a legend just add "legend position = north east" and than legend{A, B, C} as you did in your example. And in your example you made three columns. For one column write addplot coordinates {(y1, x1), (y2, x2), (y3, x3)}. To change the space between then, adjust the ybar value. Regards

            – Markus_J.
            Mar 27 at 16:03



















          • Thank you very much for your answer. How would I get a legend as in my example above. That was the reason why I put all three bars in the same column, but then I could not adjust the space between them. Sorry for my newbie questions, but I googled a lot and unfortunately could not find a satisfying answer.

            – user184165
            Mar 24 at 17:04











          • You are welcome ;). For a legend just add "legend position = north east" and than legend{A, B, C} as you did in your example. And in your example you made three columns. For one column write addplot coordinates {(y1, x1), (y2, x2), (y3, x3)}. To change the space between then, adjust the ybar value. Regards

            – Markus_J.
            Mar 27 at 16:03

















          Thank you very much for your answer. How would I get a legend as in my example above. That was the reason why I put all three bars in the same column, but then I could not adjust the space between them. Sorry for my newbie questions, but I googled a lot and unfortunately could not find a satisfying answer.

          – user184165
          Mar 24 at 17:04





          Thank you very much for your answer. How would I get a legend as in my example above. That was the reason why I put all three bars in the same column, but then I could not adjust the space between them. Sorry for my newbie questions, but I googled a lot and unfortunately could not find a satisfying answer.

          – user184165
          Mar 24 at 17:04













          You are welcome ;). For a legend just add "legend position = north east" and than legend{A, B, C} as you did in your example. And in your example you made three columns. For one column write addplot coordinates {(y1, x1), (y2, x2), (y3, x3)}. To change the space between then, adjust the ybar value. Regards

          – Markus_J.
          Mar 27 at 16:03





          You are welcome ;). For a legend just add "legend position = north east" and than legend{A, B, C} as you did in your example. And in your example you made three columns. For one column write addplot coordinates {(y1, x1), (y2, x2), (y3, x3)}. To change the space between then, adjust the ybar value. Regards

          – Markus_J.
          Mar 27 at 16:03


















          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%2f481177%2ftikz-barchart-space-between-bars-within-group%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

          mysqli_query(): Empty query in /home/lucindabrummitt/public_html/blog/wp-includes/wp-db.php on line 1924

          How to change which sound is reproduced for terminal bell?

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