How to change a figure's size in Python Seaborn package












17















I'm having trouble increasing the size of my plot figures using Seaborn. I'm using sns.pairplot to plot columns of a data frame against one another.



    %matplotlib inline
plt.rcParams['figure.figsize']=10,10
columns=list(df.columns.values)
g=sns.pairplot(df, kind='reg', x_vars=columns,y_vars = ['Column 1'])


The plots populate with data just fine, but the figure size is too small. I thought plot.rCParams['figure.figsize'] would control how large the figure is, but it doesn't seem to take effect. I've tried a few different suggestions from online boards, but nothing seems to work.










share|improve this question


















  • 2





    Did you try the size parameter in pairplot?

    – mwaskom
    Oct 31 '15 at 0:36











  • Tried setting size=5 in pairplot to make the images bigger but didn't seem to take effect. I think the problem is that seaborn is trying to place all 10 plots into a single row adjascent to one another, and that makes it too large for the screen unless the plots are shrunk down. I was able to get this to work by plotting the data frame columns separately, but I figured seaborn would have a way to subplot the data frame columns onto different rows automatically without shrinking them down.

    – Vikram Josyula
    Nov 1 '15 at 18:28











  • are you viewing these in a notebook? save them as images and i promise they'll be bigger with size=5

    – Paul H
    Nov 2 '15 at 5:56
















17















I'm having trouble increasing the size of my plot figures using Seaborn. I'm using sns.pairplot to plot columns of a data frame against one another.



    %matplotlib inline
plt.rcParams['figure.figsize']=10,10
columns=list(df.columns.values)
g=sns.pairplot(df, kind='reg', x_vars=columns,y_vars = ['Column 1'])


The plots populate with data just fine, but the figure size is too small. I thought plot.rCParams['figure.figsize'] would control how large the figure is, but it doesn't seem to take effect. I've tried a few different suggestions from online boards, but nothing seems to work.










share|improve this question


















  • 2





    Did you try the size parameter in pairplot?

    – mwaskom
    Oct 31 '15 at 0:36











  • Tried setting size=5 in pairplot to make the images bigger but didn't seem to take effect. I think the problem is that seaborn is trying to place all 10 plots into a single row adjascent to one another, and that makes it too large for the screen unless the plots are shrunk down. I was able to get this to work by plotting the data frame columns separately, but I figured seaborn would have a way to subplot the data frame columns onto different rows automatically without shrinking them down.

    – Vikram Josyula
    Nov 1 '15 at 18:28











  • are you viewing these in a notebook? save them as images and i promise they'll be bigger with size=5

    – Paul H
    Nov 2 '15 at 5:56














17












17








17


4






I'm having trouble increasing the size of my plot figures using Seaborn. I'm using sns.pairplot to plot columns of a data frame against one another.



    %matplotlib inline
plt.rcParams['figure.figsize']=10,10
columns=list(df.columns.values)
g=sns.pairplot(df, kind='reg', x_vars=columns,y_vars = ['Column 1'])


The plots populate with data just fine, but the figure size is too small. I thought plot.rCParams['figure.figsize'] would control how large the figure is, but it doesn't seem to take effect. I've tried a few different suggestions from online boards, but nothing seems to work.










share|improve this question














I'm having trouble increasing the size of my plot figures using Seaborn. I'm using sns.pairplot to plot columns of a data frame against one another.



    %matplotlib inline
plt.rcParams['figure.figsize']=10,10
columns=list(df.columns.values)
g=sns.pairplot(df, kind='reg', x_vars=columns,y_vars = ['Column 1'])


The plots populate with data just fine, but the figure size is too small. I thought plot.rCParams['figure.figsize'] would control how large the figure is, but it doesn't seem to take effect. I've tried a few different suggestions from online boards, but nothing seems to work.







python plot seaborn






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Oct 30 '15 at 22:54









Vikram JosyulaVikram Josyula

2412514




2412514








  • 2





    Did you try the size parameter in pairplot?

    – mwaskom
    Oct 31 '15 at 0:36











  • Tried setting size=5 in pairplot to make the images bigger but didn't seem to take effect. I think the problem is that seaborn is trying to place all 10 plots into a single row adjascent to one another, and that makes it too large for the screen unless the plots are shrunk down. I was able to get this to work by plotting the data frame columns separately, but I figured seaborn would have a way to subplot the data frame columns onto different rows automatically without shrinking them down.

    – Vikram Josyula
    Nov 1 '15 at 18:28











  • are you viewing these in a notebook? save them as images and i promise they'll be bigger with size=5

    – Paul H
    Nov 2 '15 at 5:56














  • 2





    Did you try the size parameter in pairplot?

    – mwaskom
    Oct 31 '15 at 0:36











  • Tried setting size=5 in pairplot to make the images bigger but didn't seem to take effect. I think the problem is that seaborn is trying to place all 10 plots into a single row adjascent to one another, and that makes it too large for the screen unless the plots are shrunk down. I was able to get this to work by plotting the data frame columns separately, but I figured seaborn would have a way to subplot the data frame columns onto different rows automatically without shrinking them down.

    – Vikram Josyula
    Nov 1 '15 at 18:28











  • are you viewing these in a notebook? save them as images and i promise they'll be bigger with size=5

    – Paul H
    Nov 2 '15 at 5:56








2




2





Did you try the size parameter in pairplot?

– mwaskom
Oct 31 '15 at 0:36





Did you try the size parameter in pairplot?

– mwaskom
Oct 31 '15 at 0:36













Tried setting size=5 in pairplot to make the images bigger but didn't seem to take effect. I think the problem is that seaborn is trying to place all 10 plots into a single row adjascent to one another, and that makes it too large for the screen unless the plots are shrunk down. I was able to get this to work by plotting the data frame columns separately, but I figured seaborn would have a way to subplot the data frame columns onto different rows automatically without shrinking them down.

– Vikram Josyula
Nov 1 '15 at 18:28





Tried setting size=5 in pairplot to make the images bigger but didn't seem to take effect. I think the problem is that seaborn is trying to place all 10 plots into a single row adjascent to one another, and that makes it too large for the screen unless the plots are shrunk down. I was able to get this to work by plotting the data frame columns separately, but I figured seaborn would have a way to subplot the data frame columns onto different rows automatically without shrinking them down.

– Vikram Josyula
Nov 1 '15 at 18:28













are you viewing these in a notebook? save them as images and i promise they'll be bigger with size=5

– Paul H
Nov 2 '15 at 5:56





are you viewing these in a notebook? save them as images and i promise they'll be bigger with size=5

– Paul H
Nov 2 '15 at 5:56












5 Answers
5






active

oldest

votes


















20














Try to put the size in parenthesis, this does the trick for me:



plt.rcParams['figure.figsize']=(10,10)





share|improve this answer


























  • This does not necessarily work. Use the other answer instead.

    – ImportanceOfBeingErnest
    Jul 20 '18 at 13:09



















13














sns.pairplot
"Returns the underlying PairGrid instance for further tweaking"
...for instance changing the figure size:



g=sns.pairplot(df, kind='reg', x_vars=columns,y_vars = ['Column 1'])
g.fig.set_size_inches(15,15)





share|improve this answer































    4














    In addition to the well working answer by @MartinAnderson, seaborn itself provides the option to set the height of the subplots of the grid. In combination with the aspect this determines the overall size of the figure in dependence of the number of subplots in the grid.



    In seaborn <= 0.8.1:



    g = sns.pairplot(..., size=10, aspect=0.6)


    In seaborn >= 0.9.0:



    g = sns.pairplot(..., height=10, aspect=0.6)


    Note that this applies to all seaborn functions which generate a figure level grid, like
    pairplot, relplot, catplot, lmplot and the underlying PairGrid or FacetGrid.



    For other seaborn plots, which directly plot to axes, the solutions from How do you change the size of figures drawn with matplotlib? will work fine.






    share|improve this answer































      1














      If we would like to change only the height or width then we can do



      g = sns.pairplot(df, kind='reg', x_vars=columns,y_vars = ['Column 1'])
      g.fig.set_figheight(6)
      g.fig.set_figwidth(10)





      share|improve this answer

































        0














        Reffering to Rahul's question about sns.catplot ( Unable to change the plot size with matplotlib and seaborn )



        If you try in jupyter notebook:



        plt.figure(figsize=(25,20))
        sns.boxplot(x='CriticRating', y='AudienceRating', data=movies)


        it is working, but



        sns.boxplot(x='CriticRating', y='AudienceRating', data=movies)
        plt.figure(figsize=(25,20))


        is not working (plot is very small). It's important to add line plt.figure(figsize=(25,20)) before sns.boxplot()and include %matplotlib inline of course in order to display plot in jupyter.






        share|improve this answer
























        • This answer works for boxplot, but not for any of the plots that create the figure itself like pairplot (this question) or catplot (the question you link to).

          – ImportanceOfBeingErnest
          Jul 20 '18 at 13:28













        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%2f33446029%2fhow-to-change-a-figures-size-in-python-seaborn-package%23new-answer', 'question_page');
        }
        );

        Post as a guest















        Required, but never shown

























        5 Answers
        5






        active

        oldest

        votes








        5 Answers
        5






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes









        20














        Try to put the size in parenthesis, this does the trick for me:



        plt.rcParams['figure.figsize']=(10,10)





        share|improve this answer


























        • This does not necessarily work. Use the other answer instead.

          – ImportanceOfBeingErnest
          Jul 20 '18 at 13:09
















        20














        Try to put the size in parenthesis, this does the trick for me:



        plt.rcParams['figure.figsize']=(10,10)





        share|improve this answer


























        • This does not necessarily work. Use the other answer instead.

          – ImportanceOfBeingErnest
          Jul 20 '18 at 13:09














        20












        20








        20







        Try to put the size in parenthesis, this does the trick for me:



        plt.rcParams['figure.figsize']=(10,10)





        share|improve this answer















        Try to put the size in parenthesis, this does the trick for me:



        plt.rcParams['figure.figsize']=(10,10)






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Nov 15 '16 at 5:17









        maxymoo

        20.1k34269




        20.1k34269










        answered Mar 16 '16 at 10:13









        S.ZuoS.Zuo

        39934




        39934













        • This does not necessarily work. Use the other answer instead.

          – ImportanceOfBeingErnest
          Jul 20 '18 at 13:09



















        • This does not necessarily work. Use the other answer instead.

          – ImportanceOfBeingErnest
          Jul 20 '18 at 13:09

















        This does not necessarily work. Use the other answer instead.

        – ImportanceOfBeingErnest
        Jul 20 '18 at 13:09





        This does not necessarily work. Use the other answer instead.

        – ImportanceOfBeingErnest
        Jul 20 '18 at 13:09













        13














        sns.pairplot
        "Returns the underlying PairGrid instance for further tweaking"
        ...for instance changing the figure size:



        g=sns.pairplot(df, kind='reg', x_vars=columns,y_vars = ['Column 1'])
        g.fig.set_size_inches(15,15)





        share|improve this answer




























          13














          sns.pairplot
          "Returns the underlying PairGrid instance for further tweaking"
          ...for instance changing the figure size:



          g=sns.pairplot(df, kind='reg', x_vars=columns,y_vars = ['Column 1'])
          g.fig.set_size_inches(15,15)





          share|improve this answer


























            13












            13








            13







            sns.pairplot
            "Returns the underlying PairGrid instance for further tweaking"
            ...for instance changing the figure size:



            g=sns.pairplot(df, kind='reg', x_vars=columns,y_vars = ['Column 1'])
            g.fig.set_size_inches(15,15)





            share|improve this answer













            sns.pairplot
            "Returns the underlying PairGrid instance for further tweaking"
            ...for instance changing the figure size:



            g=sns.pairplot(df, kind='reg', x_vars=columns,y_vars = ['Column 1'])
            g.fig.set_size_inches(15,15)






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Sep 21 '17 at 14:35









            Martin AlexanderssonMartin Alexandersson

            24125




            24125























                4














                In addition to the well working answer by @MartinAnderson, seaborn itself provides the option to set the height of the subplots of the grid. In combination with the aspect this determines the overall size of the figure in dependence of the number of subplots in the grid.



                In seaborn <= 0.8.1:



                g = sns.pairplot(..., size=10, aspect=0.6)


                In seaborn >= 0.9.0:



                g = sns.pairplot(..., height=10, aspect=0.6)


                Note that this applies to all seaborn functions which generate a figure level grid, like
                pairplot, relplot, catplot, lmplot and the underlying PairGrid or FacetGrid.



                For other seaborn plots, which directly plot to axes, the solutions from How do you change the size of figures drawn with matplotlib? will work fine.






                share|improve this answer




























                  4














                  In addition to the well working answer by @MartinAnderson, seaborn itself provides the option to set the height of the subplots of the grid. In combination with the aspect this determines the overall size of the figure in dependence of the number of subplots in the grid.



                  In seaborn <= 0.8.1:



                  g = sns.pairplot(..., size=10, aspect=0.6)


                  In seaborn >= 0.9.0:



                  g = sns.pairplot(..., height=10, aspect=0.6)


                  Note that this applies to all seaborn functions which generate a figure level grid, like
                  pairplot, relplot, catplot, lmplot and the underlying PairGrid or FacetGrid.



                  For other seaborn plots, which directly plot to axes, the solutions from How do you change the size of figures drawn with matplotlib? will work fine.






                  share|improve this answer


























                    4












                    4








                    4







                    In addition to the well working answer by @MartinAnderson, seaborn itself provides the option to set the height of the subplots of the grid. In combination with the aspect this determines the overall size of the figure in dependence of the number of subplots in the grid.



                    In seaborn <= 0.8.1:



                    g = sns.pairplot(..., size=10, aspect=0.6)


                    In seaborn >= 0.9.0:



                    g = sns.pairplot(..., height=10, aspect=0.6)


                    Note that this applies to all seaborn functions which generate a figure level grid, like
                    pairplot, relplot, catplot, lmplot and the underlying PairGrid or FacetGrid.



                    For other seaborn plots, which directly plot to axes, the solutions from How do you change the size of figures drawn with matplotlib? will work fine.






                    share|improve this answer













                    In addition to the well working answer by @MartinAnderson, seaborn itself provides the option to set the height of the subplots of the grid. In combination with the aspect this determines the overall size of the figure in dependence of the number of subplots in the grid.



                    In seaborn <= 0.8.1:



                    g = sns.pairplot(..., size=10, aspect=0.6)


                    In seaborn >= 0.9.0:



                    g = sns.pairplot(..., height=10, aspect=0.6)


                    Note that this applies to all seaborn functions which generate a figure level grid, like
                    pairplot, relplot, catplot, lmplot and the underlying PairGrid or FacetGrid.



                    For other seaborn plots, which directly plot to axes, the solutions from How do you change the size of figures drawn with matplotlib? will work fine.







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Jul 20 '18 at 13:41









                    ImportanceOfBeingErnestImportanceOfBeingErnest

                    133k13148224




                    133k13148224























                        1














                        If we would like to change only the height or width then we can do



                        g = sns.pairplot(df, kind='reg', x_vars=columns,y_vars = ['Column 1'])
                        g.fig.set_figheight(6)
                        g.fig.set_figwidth(10)





                        share|improve this answer






























                          1














                          If we would like to change only the height or width then we can do



                          g = sns.pairplot(df, kind='reg', x_vars=columns,y_vars = ['Column 1'])
                          g.fig.set_figheight(6)
                          g.fig.set_figwidth(10)





                          share|improve this answer




























                            1












                            1








                            1







                            If we would like to change only the height or width then we can do



                            g = sns.pairplot(df, kind='reg', x_vars=columns,y_vars = ['Column 1'])
                            g.fig.set_figheight(6)
                            g.fig.set_figwidth(10)





                            share|improve this answer















                            If we would like to change only the height or width then we can do



                            g = sns.pairplot(df, kind='reg', x_vars=columns,y_vars = ['Column 1'])
                            g.fig.set_figheight(6)
                            g.fig.set_figwidth(10)






                            share|improve this answer














                            share|improve this answer



                            share|improve this answer








                            edited Nov 24 '18 at 16:19

























                            answered Jul 24 '18 at 17:42









                            JeevanJeevan

                            5,24384057




                            5,24384057























                                0














                                Reffering to Rahul's question about sns.catplot ( Unable to change the plot size with matplotlib and seaborn )



                                If you try in jupyter notebook:



                                plt.figure(figsize=(25,20))
                                sns.boxplot(x='CriticRating', y='AudienceRating', data=movies)


                                it is working, but



                                sns.boxplot(x='CriticRating', y='AudienceRating', data=movies)
                                plt.figure(figsize=(25,20))


                                is not working (plot is very small). It's important to add line plt.figure(figsize=(25,20)) before sns.boxplot()and include %matplotlib inline of course in order to display plot in jupyter.






                                share|improve this answer
























                                • This answer works for boxplot, but not for any of the plots that create the figure itself like pairplot (this question) or catplot (the question you link to).

                                  – ImportanceOfBeingErnest
                                  Jul 20 '18 at 13:28


















                                0














                                Reffering to Rahul's question about sns.catplot ( Unable to change the plot size with matplotlib and seaborn )



                                If you try in jupyter notebook:



                                plt.figure(figsize=(25,20))
                                sns.boxplot(x='CriticRating', y='AudienceRating', data=movies)


                                it is working, but



                                sns.boxplot(x='CriticRating', y='AudienceRating', data=movies)
                                plt.figure(figsize=(25,20))


                                is not working (plot is very small). It's important to add line plt.figure(figsize=(25,20)) before sns.boxplot()and include %matplotlib inline of course in order to display plot in jupyter.






                                share|improve this answer
























                                • This answer works for boxplot, but not for any of the plots that create the figure itself like pairplot (this question) or catplot (the question you link to).

                                  – ImportanceOfBeingErnest
                                  Jul 20 '18 at 13:28
















                                0












                                0








                                0







                                Reffering to Rahul's question about sns.catplot ( Unable to change the plot size with matplotlib and seaborn )



                                If you try in jupyter notebook:



                                plt.figure(figsize=(25,20))
                                sns.boxplot(x='CriticRating', y='AudienceRating', data=movies)


                                it is working, but



                                sns.boxplot(x='CriticRating', y='AudienceRating', data=movies)
                                plt.figure(figsize=(25,20))


                                is not working (plot is very small). It's important to add line plt.figure(figsize=(25,20)) before sns.boxplot()and include %matplotlib inline of course in order to display plot in jupyter.






                                share|improve this answer













                                Reffering to Rahul's question about sns.catplot ( Unable to change the plot size with matplotlib and seaborn )



                                If you try in jupyter notebook:



                                plt.figure(figsize=(25,20))
                                sns.boxplot(x='CriticRating', y='AudienceRating', data=movies)


                                it is working, but



                                sns.boxplot(x='CriticRating', y='AudienceRating', data=movies)
                                plt.figure(figsize=(25,20))


                                is not working (plot is very small). It's important to add line plt.figure(figsize=(25,20)) before sns.boxplot()and include %matplotlib inline of course in order to display plot in jupyter.







                                share|improve this answer












                                share|improve this answer



                                share|improve this answer










                                answered Jul 20 '18 at 13:08









                                Dejan MarićDejan Marić

                                438212




                                438212













                                • This answer works for boxplot, but not for any of the plots that create the figure itself like pairplot (this question) or catplot (the question you link to).

                                  – ImportanceOfBeingErnest
                                  Jul 20 '18 at 13:28





















                                • This answer works for boxplot, but not for any of the plots that create the figure itself like pairplot (this question) or catplot (the question you link to).

                                  – ImportanceOfBeingErnest
                                  Jul 20 '18 at 13:28



















                                This answer works for boxplot, but not for any of the plots that create the figure itself like pairplot (this question) or catplot (the question you link to).

                                – ImportanceOfBeingErnest
                                Jul 20 '18 at 13:28







                                This answer works for boxplot, but not for any of the plots that create the figure itself like pairplot (this question) or catplot (the question you link to).

                                – ImportanceOfBeingErnest
                                Jul 20 '18 at 13:28




















                                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%2f33446029%2fhow-to-change-a-figures-size-in-python-seaborn-package%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

                                404 Error Contact Form 7 ajax form submitting

                                How to know if a Active Directory user can login interactively

                                Refactoring coordinates for Minecraft Pi buildings written in Python