How to set the y coordinate(s) of the bars bases in gnuplot bar charts?










1














Is there any way to set the y coordinate(s) of the bars bases in gnuplot bar charts as the bottom option in matplotlib?



For example, suppose I have the following data:



0.5 0.2 0.3 0.1 0.2 0.1
0.6 0.1 0.2 0.1 0.2 0.0
0.4 0.2 0.1 0.1 0.5 0.3


In matplotlib I can do the following procedure:



import matplotlib.pyplot as plt
import numpy as np

a = np.loadtxt('sample.dat', usecols=[0], dtype=float).tolist()
a1 = np.loadtxt('sample.dat', usecols=[1], dtype=float).tolist()
b = np.loadtxt('sample.dat', usecols=[2], dtype=float).tolist()
b1 = np.loadtxt('sample.dat', usecols=[3], dtype=float).tolist()
c = np.loadtxt('sample.dat', usecols=[4], dtype=float).tolist()
c1 = np.loadtxt('sample.dat', usecols=[5], dtype=float).tolist()

x_pos = np.arange(len(a))
plt.bar(x_pos,a, align='center', color='green');
plt.bar(x_pos,b, align='center', bottom=a, color='red');
plt.bar(x_pos,c, align='center', bottom=np.add(a, b).tolist(), color='orange');
plt.bar(x_pos,a1, align='center', bottom=None, color='black');
plt.bar(x_pos,b1, align='center', bottom=a, color='blue');
plt.bar(x_pos,c1, align='center', bottom=np.add(a, b).tolist(), color='gray');
plt.xticks(np.arange(0, len(a)));


Getting the following graph:



Bar chart










share|improve this question


























    1














    Is there any way to set the y coordinate(s) of the bars bases in gnuplot bar charts as the bottom option in matplotlib?



    For example, suppose I have the following data:



    0.5 0.2 0.3 0.1 0.2 0.1
    0.6 0.1 0.2 0.1 0.2 0.0
    0.4 0.2 0.1 0.1 0.5 0.3


    In matplotlib I can do the following procedure:



    import matplotlib.pyplot as plt
    import numpy as np

    a = np.loadtxt('sample.dat', usecols=[0], dtype=float).tolist()
    a1 = np.loadtxt('sample.dat', usecols=[1], dtype=float).tolist()
    b = np.loadtxt('sample.dat', usecols=[2], dtype=float).tolist()
    b1 = np.loadtxt('sample.dat', usecols=[3], dtype=float).tolist()
    c = np.loadtxt('sample.dat', usecols=[4], dtype=float).tolist()
    c1 = np.loadtxt('sample.dat', usecols=[5], dtype=float).tolist()

    x_pos = np.arange(len(a))
    plt.bar(x_pos,a, align='center', color='green');
    plt.bar(x_pos,b, align='center', bottom=a, color='red');
    plt.bar(x_pos,c, align='center', bottom=np.add(a, b).tolist(), color='orange');
    plt.bar(x_pos,a1, align='center', bottom=None, color='black');
    plt.bar(x_pos,b1, align='center', bottom=a, color='blue');
    plt.bar(x_pos,c1, align='center', bottom=np.add(a, b).tolist(), color='gray');
    plt.xticks(np.arange(0, len(a)));


    Getting the following graph:



    Bar chart










    share|improve this question
























      1












      1








      1







      Is there any way to set the y coordinate(s) of the bars bases in gnuplot bar charts as the bottom option in matplotlib?



      For example, suppose I have the following data:



      0.5 0.2 0.3 0.1 0.2 0.1
      0.6 0.1 0.2 0.1 0.2 0.0
      0.4 0.2 0.1 0.1 0.5 0.3


      In matplotlib I can do the following procedure:



      import matplotlib.pyplot as plt
      import numpy as np

      a = np.loadtxt('sample.dat', usecols=[0], dtype=float).tolist()
      a1 = np.loadtxt('sample.dat', usecols=[1], dtype=float).tolist()
      b = np.loadtxt('sample.dat', usecols=[2], dtype=float).tolist()
      b1 = np.loadtxt('sample.dat', usecols=[3], dtype=float).tolist()
      c = np.loadtxt('sample.dat', usecols=[4], dtype=float).tolist()
      c1 = np.loadtxt('sample.dat', usecols=[5], dtype=float).tolist()

      x_pos = np.arange(len(a))
      plt.bar(x_pos,a, align='center', color='green');
      plt.bar(x_pos,b, align='center', bottom=a, color='red');
      plt.bar(x_pos,c, align='center', bottom=np.add(a, b).tolist(), color='orange');
      plt.bar(x_pos,a1, align='center', bottom=None, color='black');
      plt.bar(x_pos,b1, align='center', bottom=a, color='blue');
      plt.bar(x_pos,c1, align='center', bottom=np.add(a, b).tolist(), color='gray');
      plt.xticks(np.arange(0, len(a)));


      Getting the following graph:



      Bar chart










      share|improve this question













      Is there any way to set the y coordinate(s) of the bars bases in gnuplot bar charts as the bottom option in matplotlib?



      For example, suppose I have the following data:



      0.5 0.2 0.3 0.1 0.2 0.1
      0.6 0.1 0.2 0.1 0.2 0.0
      0.4 0.2 0.1 0.1 0.5 0.3


      In matplotlib I can do the following procedure:



      import matplotlib.pyplot as plt
      import numpy as np

      a = np.loadtxt('sample.dat', usecols=[0], dtype=float).tolist()
      a1 = np.loadtxt('sample.dat', usecols=[1], dtype=float).tolist()
      b = np.loadtxt('sample.dat', usecols=[2], dtype=float).tolist()
      b1 = np.loadtxt('sample.dat', usecols=[3], dtype=float).tolist()
      c = np.loadtxt('sample.dat', usecols=[4], dtype=float).tolist()
      c1 = np.loadtxt('sample.dat', usecols=[5], dtype=float).tolist()

      x_pos = np.arange(len(a))
      plt.bar(x_pos,a, align='center', color='green');
      plt.bar(x_pos,b, align='center', bottom=a, color='red');
      plt.bar(x_pos,c, align='center', bottom=np.add(a, b).tolist(), color='orange');
      plt.bar(x_pos,a1, align='center', bottom=None, color='black');
      plt.bar(x_pos,b1, align='center', bottom=a, color='blue');
      plt.bar(x_pos,c1, align='center', bottom=np.add(a, b).tolist(), color='gray');
      plt.xticks(np.arange(0, len(a)));


      Getting the following graph:



      Bar chart







      gnuplot






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 10 at 22:51









      zoh85429

      61




      61






















          1 Answer
          1






          active

          oldest

          votes


















          1














          There is a gnuplot plot style that allows you to specify both the top and bottom of each box (and the left and right also). It is



          plot FOO using (x):(y):(xlow):(xhigh):(ylow):(yhigh) with boxxy


          However there is a much better was of generating stacked histogram plots such as the one you show.



          set style data histogram
          set style histogram columnstacked
          set style fill solid border lc "black"
          plot for [col=4:7] FOO using col title sprintf("Col %d",col)


          enter image description here






          share|improve this answer




















            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            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: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            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%2fstackoverflow.com%2fquestions%2f53244201%2fhow-to-set-the-y-coordinates-of-the-bars-bases-in-gnuplot-bar-charts%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














            There is a gnuplot plot style that allows you to specify both the top and bottom of each box (and the left and right also). It is



            plot FOO using (x):(y):(xlow):(xhigh):(ylow):(yhigh) with boxxy


            However there is a much better was of generating stacked histogram plots such as the one you show.



            set style data histogram
            set style histogram columnstacked
            set style fill solid border lc "black"
            plot for [col=4:7] FOO using col title sprintf("Col %d",col)


            enter image description here






            share|improve this answer

























              1














              There is a gnuplot plot style that allows you to specify both the top and bottom of each box (and the left and right also). It is



              plot FOO using (x):(y):(xlow):(xhigh):(ylow):(yhigh) with boxxy


              However there is a much better was of generating stacked histogram plots such as the one you show.



              set style data histogram
              set style histogram columnstacked
              set style fill solid border lc "black"
              plot for [col=4:7] FOO using col title sprintf("Col %d",col)


              enter image description here






              share|improve this answer























                1












                1








                1






                There is a gnuplot plot style that allows you to specify both the top and bottom of each box (and the left and right also). It is



                plot FOO using (x):(y):(xlow):(xhigh):(ylow):(yhigh) with boxxy


                However there is a much better was of generating stacked histogram plots such as the one you show.



                set style data histogram
                set style histogram columnstacked
                set style fill solid border lc "black"
                plot for [col=4:7] FOO using col title sprintf("Col %d",col)


                enter image description here






                share|improve this answer












                There is a gnuplot plot style that allows you to specify both the top and bottom of each box (and the left and right also). It is



                plot FOO using (x):(y):(xlow):(xhigh):(ylow):(yhigh) with boxxy


                However there is a much better was of generating stacked histogram plots such as the one you show.



                set style data histogram
                set style histogram columnstacked
                set style fill solid border lc "black"
                plot for [col=4:7] FOO using col title sprintf("Col %d",col)


                enter image description here







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 11 at 4:29









                Ethan Merritt

                1,591257




                1,591257



























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • 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%2fstackoverflow.com%2fquestions%2f53244201%2fhow-to-set-the-y-coordinates-of-the-bars-bases-in-gnuplot-bar-charts%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

                    Top Tejano songwriter Luis Silva dead of heart attack at 64

                    政党

                    天津地下鉄3号線