Changing distance between categories when plotting FacetGrid with error barsHow to change the font size on a matplotlib plotWhen to use cla(), clf() or close() for clearing a plot in matplotlib?pandas plots on Seaborn FacetGridHow to add legend on Seaborn facetgrid bar plotIncrease space between rows on FacetGrid plotPython: Plot scatter plot with category and markersizePlotting mean lines for different 'hue' data on a Seaborn FacetGrid plotSeaborn FacetGrid legend loses linestyle details when changing linewidthseaborn bar chart for categorical data, groupedHow to add a comparison line to all plots when using Seaborn's FacetGrid

Will using a resistor in series with a LED to control its voltage increase the total energy expenditure?

Why does my purified Pokémon need to be healed?

Why did IBM make public the PC BIOS source code?

Simplification of numbers

What are those bumps on top of the Antonov-225?

Do Reform Jews believe in a theistic God?

If you know the location of an invisible creature, can you attack it?

How can God warn people of the upcoming rapture without disrupting society?

Boss asked a co-worker to assault me

How was the murder committed?

The cat exchanges places with a drawing of the cat

How far did Gandalf and the Balrog drop from the bridge in Moria?

Are those flyers about apartment purchase a scam?

Concat Loop Results to determine if contains value

How do I call a 6 digit Austrailian phone number with a US based mobile phone?

PhD advisor lost funding, need advice

Modeling the uncertainty of the input parameters

Does one make a shehecheyanu on "used" jewelry?

How do some PhD students get 10+ papers? Is that what I need for landing good faculty position?

What kind of liquid can be seen 'leaking' from the upper surface of the wing of a Boeing 737-800?

Telephone number in spoken words

Can the IPA represent all languages' tones?

Using hearing aids on the sabbath?

Help, I cannot decide when to start the story



Changing distance between categories when plotting FacetGrid with error bars


How to change the font size on a matplotlib plotWhen to use cla(), clf() or close() for clearing a plot in matplotlib?pandas plots on Seaborn FacetGridHow to add legend on Seaborn facetgrid bar plotIncrease space between rows on FacetGrid plotPython: Plot scatter plot with category and markersizePlotting mean lines for different 'hue' data on a Seaborn FacetGrid plotSeaborn FacetGrid legend loses linestyle details when changing linewidthseaborn bar chart for categorical data, groupedHow to add a comparison line to all plots when using Seaborn's FacetGrid






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I am using FacetGrid from Seaborn together with errorbar from Matplotlib to generate a graph that has two categories in the y axis. I want to center the two categories (get them closer to each other and more distant to the margins).



I have tried to change height/aspect to achieve that without success. I am sharing the code below. Thanks!



import matplotlib.pyplot as plt 
import seaborn as sns
import pandas as pd

cat = ['a','b','a','a','a','b','b','a']
var=[3,5,4,6,7,5,6,3]
sd_var = [0.1,0.3,0.1,0.5,0.4,0.2,0.1,0.2]

df = pd.DataFrame('cat' : cat, 'var' : var, 'sd_var' : sd_var)

g = sns.FacetGrid(data=df, hue="cat", aspect=1, height=6)
g.map(plt.errorbar, "cat", "var", "sd_var", marker="o",
linestyle='',markersize='6', capsize=4, elinewidth=2)

plt.show()









share|improve this question
































    0















    I am using FacetGrid from Seaborn together with errorbar from Matplotlib to generate a graph that has two categories in the y axis. I want to center the two categories (get them closer to each other and more distant to the margins).



    I have tried to change height/aspect to achieve that without success. I am sharing the code below. Thanks!



    import matplotlib.pyplot as plt 
    import seaborn as sns
    import pandas as pd

    cat = ['a','b','a','a','a','b','b','a']
    var=[3,5,4,6,7,5,6,3]
    sd_var = [0.1,0.3,0.1,0.5,0.4,0.2,0.1,0.2]

    df = pd.DataFrame('cat' : cat, 'var' : var, 'sd_var' : sd_var)

    g = sns.FacetGrid(data=df, hue="cat", aspect=1, height=6)
    g.map(plt.errorbar, "cat", "var", "sd_var", marker="o",
    linestyle='',markersize='6', capsize=4, elinewidth=2)

    plt.show()









    share|improve this question




























      0












      0








      0








      I am using FacetGrid from Seaborn together with errorbar from Matplotlib to generate a graph that has two categories in the y axis. I want to center the two categories (get them closer to each other and more distant to the margins).



      I have tried to change height/aspect to achieve that without success. I am sharing the code below. Thanks!



      import matplotlib.pyplot as plt 
      import seaborn as sns
      import pandas as pd

      cat = ['a','b','a','a','a','b','b','a']
      var=[3,5,4,6,7,5,6,3]
      sd_var = [0.1,0.3,0.1,0.5,0.4,0.2,0.1,0.2]

      df = pd.DataFrame('cat' : cat, 'var' : var, 'sd_var' : sd_var)

      g = sns.FacetGrid(data=df, hue="cat", aspect=1, height=6)
      g.map(plt.errorbar, "cat", "var", "sd_var", marker="o",
      linestyle='',markersize='6', capsize=4, elinewidth=2)

      plt.show()









      share|improve this question
















      I am using FacetGrid from Seaborn together with errorbar from Matplotlib to generate a graph that has two categories in the y axis. I want to center the two categories (get them closer to each other and more distant to the margins).



      I have tried to change height/aspect to achieve that without success. I am sharing the code below. Thanks!



      import matplotlib.pyplot as plt 
      import seaborn as sns
      import pandas as pd

      cat = ['a','b','a','a','a','b','b','a']
      var=[3,5,4,6,7,5,6,3]
      sd_var = [0.1,0.3,0.1,0.5,0.4,0.2,0.1,0.2]

      df = pd.DataFrame('cat' : cat, 'var' : var, 'sd_var' : sd_var)

      g = sns.FacetGrid(data=df, hue="cat", aspect=1, height=6)
      g.map(plt.errorbar, "cat", "var", "sd_var", marker="o",
      linestyle='',markersize='6', capsize=4, elinewidth=2)

      plt.show()






      python matplotlib seaborn errorbar facet-grid






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 28 at 1:11







      Daniela Osorio

















      asked Mar 26 at 23:18









      Daniela OsorioDaniela Osorio

      11 bronze badge




      11 bronze badge

























          1 Answer
          1






          active

          oldest

          votes


















          0














          You are pretty close to it



          import matplotlib.pyplot as plt 
          import seaborn as sns
          import pandas as pd

          # replace label with actual number
          cat = [1,2,1,1,1,2,2,1]
          var=[3,5,4,6,7,5,6,3]
          sd_var = [0.1,0.3,0.1,0.5,0.4,0.2,0.1,0.2]

          df = pd.DataFrame('cat' : cat, 'var' : var, 'sd_var' : sd_var)

          g = sns.FacetGrid(data=df, hue="cat", aspect=1, height=6)
          g.map(plt.errorbar, "cat", "var", "sd_var", marker="o",
          linestyle='',markersize='6', capsize=4, elinewidth=2)

          # place the ticks at center by widening the plot
          plt.xlim((0, 3))
          # fix ticks at the number encoding for each class
          g.fig.axes[0].xaxis.set_ticks([1, 2])
          # name the numbers
          g.fig.axes[0].xaxis.set_ticklabels(['a', 'b'])
          plt.show()


          The trick is to make use of relative length of the x-limit and your number encoding for the classes.



          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%2f55367551%2fchanging-distance-between-categories-when-plotting-facetgrid-with-error-bars%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














            You are pretty close to it



            import matplotlib.pyplot as plt 
            import seaborn as sns
            import pandas as pd

            # replace label with actual number
            cat = [1,2,1,1,1,2,2,1]
            var=[3,5,4,6,7,5,6,3]
            sd_var = [0.1,0.3,0.1,0.5,0.4,0.2,0.1,0.2]

            df = pd.DataFrame('cat' : cat, 'var' : var, 'sd_var' : sd_var)

            g = sns.FacetGrid(data=df, hue="cat", aspect=1, height=6)
            g.map(plt.errorbar, "cat", "var", "sd_var", marker="o",
            linestyle='',markersize='6', capsize=4, elinewidth=2)

            # place the ticks at center by widening the plot
            plt.xlim((0, 3))
            # fix ticks at the number encoding for each class
            g.fig.axes[0].xaxis.set_ticks([1, 2])
            # name the numbers
            g.fig.axes[0].xaxis.set_ticklabels(['a', 'b'])
            plt.show()


            The trick is to make use of relative length of the x-limit and your number encoding for the classes.



            enter image description here






            share|improve this answer





























              0














              You are pretty close to it



              import matplotlib.pyplot as plt 
              import seaborn as sns
              import pandas as pd

              # replace label with actual number
              cat = [1,2,1,1,1,2,2,1]
              var=[3,5,4,6,7,5,6,3]
              sd_var = [0.1,0.3,0.1,0.5,0.4,0.2,0.1,0.2]

              df = pd.DataFrame('cat' : cat, 'var' : var, 'sd_var' : sd_var)

              g = sns.FacetGrid(data=df, hue="cat", aspect=1, height=6)
              g.map(plt.errorbar, "cat", "var", "sd_var", marker="o",
              linestyle='',markersize='6', capsize=4, elinewidth=2)

              # place the ticks at center by widening the plot
              plt.xlim((0, 3))
              # fix ticks at the number encoding for each class
              g.fig.axes[0].xaxis.set_ticks([1, 2])
              # name the numbers
              g.fig.axes[0].xaxis.set_ticklabels(['a', 'b'])
              plt.show()


              The trick is to make use of relative length of the x-limit and your number encoding for the classes.



              enter image description here






              share|improve this answer



























                0












                0








                0







                You are pretty close to it



                import matplotlib.pyplot as plt 
                import seaborn as sns
                import pandas as pd

                # replace label with actual number
                cat = [1,2,1,1,1,2,2,1]
                var=[3,5,4,6,7,5,6,3]
                sd_var = [0.1,0.3,0.1,0.5,0.4,0.2,0.1,0.2]

                df = pd.DataFrame('cat' : cat, 'var' : var, 'sd_var' : sd_var)

                g = sns.FacetGrid(data=df, hue="cat", aspect=1, height=6)
                g.map(plt.errorbar, "cat", "var", "sd_var", marker="o",
                linestyle='',markersize='6', capsize=4, elinewidth=2)

                # place the ticks at center by widening the plot
                plt.xlim((0, 3))
                # fix ticks at the number encoding for each class
                g.fig.axes[0].xaxis.set_ticks([1, 2])
                # name the numbers
                g.fig.axes[0].xaxis.set_ticklabels(['a', 'b'])
                plt.show()


                The trick is to make use of relative length of the x-limit and your number encoding for the classes.



                enter image description here






                share|improve this answer













                You are pretty close to it



                import matplotlib.pyplot as plt 
                import seaborn as sns
                import pandas as pd

                # replace label with actual number
                cat = [1,2,1,1,1,2,2,1]
                var=[3,5,4,6,7,5,6,3]
                sd_var = [0.1,0.3,0.1,0.5,0.4,0.2,0.1,0.2]

                df = pd.DataFrame('cat' : cat, 'var' : var, 'sd_var' : sd_var)

                g = sns.FacetGrid(data=df, hue="cat", aspect=1, height=6)
                g.map(plt.errorbar, "cat", "var", "sd_var", marker="o",
                linestyle='',markersize='6', capsize=4, elinewidth=2)

                # place the ticks at center by widening the plot
                plt.xlim((0, 3))
                # fix ticks at the number encoding for each class
                g.fig.axes[0].xaxis.set_ticks([1, 2])
                # name the numbers
                g.fig.axes[0].xaxis.set_ticklabels(['a', 'b'])
                plt.show()


                The trick is to make use of relative length of the x-limit and your number encoding for the classes.



                enter image description here







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Mar 28 at 1:29









                PM HuiPM Hui

                1566 bronze badges




                1566 bronze badges





















                    Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







                    Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.



















                    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.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55367551%2fchanging-distance-between-categories-when-plotting-facetgrid-with-error-bars%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

                    Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

                    SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

                    은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현