Suppress output of object when plotting in ipython











up vote
9
down vote

favorite
5












Is it possible to suppress the array output when plotting a histogram in ipython?:



For example:



plt.hist(OIR['Range'], bins, named=True, histtype='bar')


outputs/prints the array information before displaying the graph.



ipython histogram http://i46.tinypic.com/jry5ba.png










share|improve this question




























    up vote
    9
    down vote

    favorite
    5












    Is it possible to suppress the array output when plotting a histogram in ipython?:



    For example:



    plt.hist(OIR['Range'], bins, named=True, histtype='bar')


    outputs/prints the array information before displaying the graph.



    ipython histogram http://i46.tinypic.com/jry5ba.png










    share|improve this question


























      up vote
      9
      down vote

      favorite
      5









      up vote
      9
      down vote

      favorite
      5






      5





      Is it possible to suppress the array output when plotting a histogram in ipython?:



      For example:



      plt.hist(OIR['Range'], bins, named=True, histtype='bar')


      outputs/prints the array information before displaying the graph.



      ipython histogram http://i46.tinypic.com/jry5ba.png










      share|improve this question















      Is it possible to suppress the array output when plotting a histogram in ipython?:



      For example:



      plt.hist(OIR['Range'], bins, named=True, histtype='bar')


      outputs/prints the array information before displaying the graph.



      ipython histogram http://i46.tinypic.com/jry5ba.png







      pandas ipython






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jan 24 '13 at 18:02









      Andy Hayden

      175k49419405




      175k49419405










      asked Jan 24 '13 at 16:54









      aozkan

      3111515




      3111515
























          3 Answers
          3






          active

          oldest

          votes

















          up vote
          13
          down vote



          accepted










          Assign the return value to a variable (which I call _ to indicate it's unused):



          _ = plt.hist(...)





          share|improve this answer





















          • Perfect thank You.
            – aozkan
            Jan 24 '13 at 17:13






          • 8




            alternately, you can suppress output by putting a semicolon at the end of the last line: plot(foo);
            – minrk
            Jan 24 '13 at 19:43


















          up vote
          24
          down vote













          just put ; after the code.

          It works only in ipython-notebook.



          plt.hist(...);






          share|improve this answer

















          • 4




            Brilliant solution! The reason this works is because the notebook shows the return value of the last command. By adding ; the last command is "nothing" so there is no return value to show.
            – kynan
            Nov 6 '15 at 13:26






          • 2




            This should be the accepted answer
            – Hennadii Madan
            Jun 13 '16 at 13:00










          • I agree that this should be the accepted answer
            – Stefaan
            Jun 16 '16 at 20:24










          • A brilliant solution followed by good explanation by @kynan
            – Lyle
            Dec 3 '16 at 10:34










          • great answer, thanks @weiz!
            – CanCeylan
            Feb 9 '17 at 21:06


















          up vote
          0
          down vote













          You can also add plt.show():



          plt.hist(OIR['Range'], bins, named=True, histtype='bar')
          plt.show()





          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',
            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%2f14506583%2fsuppress-output-of-object-when-plotting-in-ipython%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            3 Answers
            3






            active

            oldest

            votes








            3 Answers
            3






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            13
            down vote



            accepted










            Assign the return value to a variable (which I call _ to indicate it's unused):



            _ = plt.hist(...)





            share|improve this answer





















            • Perfect thank You.
              – aozkan
              Jan 24 '13 at 17:13






            • 8




              alternately, you can suppress output by putting a semicolon at the end of the last line: plot(foo);
              – minrk
              Jan 24 '13 at 19:43















            up vote
            13
            down vote



            accepted










            Assign the return value to a variable (which I call _ to indicate it's unused):



            _ = plt.hist(...)





            share|improve this answer





















            • Perfect thank You.
              – aozkan
              Jan 24 '13 at 17:13






            • 8




              alternately, you can suppress output by putting a semicolon at the end of the last line: plot(foo);
              – minrk
              Jan 24 '13 at 19:43













            up vote
            13
            down vote



            accepted







            up vote
            13
            down vote



            accepted






            Assign the return value to a variable (which I call _ to indicate it's unused):



            _ = plt.hist(...)





            share|improve this answer












            Assign the return value to a variable (which I call _ to indicate it's unused):



            _ = plt.hist(...)






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Jan 24 '13 at 17:00









            NPE

            346k60739870




            346k60739870












            • Perfect thank You.
              – aozkan
              Jan 24 '13 at 17:13






            • 8




              alternately, you can suppress output by putting a semicolon at the end of the last line: plot(foo);
              – minrk
              Jan 24 '13 at 19:43


















            • Perfect thank You.
              – aozkan
              Jan 24 '13 at 17:13






            • 8




              alternately, you can suppress output by putting a semicolon at the end of the last line: plot(foo);
              – minrk
              Jan 24 '13 at 19:43
















            Perfect thank You.
            – aozkan
            Jan 24 '13 at 17:13




            Perfect thank You.
            – aozkan
            Jan 24 '13 at 17:13




            8




            8




            alternately, you can suppress output by putting a semicolon at the end of the last line: plot(foo);
            – minrk
            Jan 24 '13 at 19:43




            alternately, you can suppress output by putting a semicolon at the end of the last line: plot(foo);
            – minrk
            Jan 24 '13 at 19:43












            up vote
            24
            down vote













            just put ; after the code.

            It works only in ipython-notebook.



            plt.hist(...);






            share|improve this answer

















            • 4




              Brilliant solution! The reason this works is because the notebook shows the return value of the last command. By adding ; the last command is "nothing" so there is no return value to show.
              – kynan
              Nov 6 '15 at 13:26






            • 2




              This should be the accepted answer
              – Hennadii Madan
              Jun 13 '16 at 13:00










            • I agree that this should be the accepted answer
              – Stefaan
              Jun 16 '16 at 20:24










            • A brilliant solution followed by good explanation by @kynan
              – Lyle
              Dec 3 '16 at 10:34










            • great answer, thanks @weiz!
              – CanCeylan
              Feb 9 '17 at 21:06















            up vote
            24
            down vote













            just put ; after the code.

            It works only in ipython-notebook.



            plt.hist(...);






            share|improve this answer

















            • 4




              Brilliant solution! The reason this works is because the notebook shows the return value of the last command. By adding ; the last command is "nothing" so there is no return value to show.
              – kynan
              Nov 6 '15 at 13:26






            • 2




              This should be the accepted answer
              – Hennadii Madan
              Jun 13 '16 at 13:00










            • I agree that this should be the accepted answer
              – Stefaan
              Jun 16 '16 at 20:24










            • A brilliant solution followed by good explanation by @kynan
              – Lyle
              Dec 3 '16 at 10:34










            • great answer, thanks @weiz!
              – CanCeylan
              Feb 9 '17 at 21:06













            up vote
            24
            down vote










            up vote
            24
            down vote









            just put ; after the code.

            It works only in ipython-notebook.



            plt.hist(...);






            share|improve this answer












            just put ; after the code.

            It works only in ipython-notebook.



            plt.hist(...);







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Aug 3 '15 at 16:17









            weiz

            1,291165




            1,291165








            • 4




              Brilliant solution! The reason this works is because the notebook shows the return value of the last command. By adding ; the last command is "nothing" so there is no return value to show.
              – kynan
              Nov 6 '15 at 13:26






            • 2




              This should be the accepted answer
              – Hennadii Madan
              Jun 13 '16 at 13:00










            • I agree that this should be the accepted answer
              – Stefaan
              Jun 16 '16 at 20:24










            • A brilliant solution followed by good explanation by @kynan
              – Lyle
              Dec 3 '16 at 10:34










            • great answer, thanks @weiz!
              – CanCeylan
              Feb 9 '17 at 21:06














            • 4




              Brilliant solution! The reason this works is because the notebook shows the return value of the last command. By adding ; the last command is "nothing" so there is no return value to show.
              – kynan
              Nov 6 '15 at 13:26






            • 2




              This should be the accepted answer
              – Hennadii Madan
              Jun 13 '16 at 13:00










            • I agree that this should be the accepted answer
              – Stefaan
              Jun 16 '16 at 20:24










            • A brilliant solution followed by good explanation by @kynan
              – Lyle
              Dec 3 '16 at 10:34










            • great answer, thanks @weiz!
              – CanCeylan
              Feb 9 '17 at 21:06








            4




            4




            Brilliant solution! The reason this works is because the notebook shows the return value of the last command. By adding ; the last command is "nothing" so there is no return value to show.
            – kynan
            Nov 6 '15 at 13:26




            Brilliant solution! The reason this works is because the notebook shows the return value of the last command. By adding ; the last command is "nothing" so there is no return value to show.
            – kynan
            Nov 6 '15 at 13:26




            2




            2




            This should be the accepted answer
            – Hennadii Madan
            Jun 13 '16 at 13:00




            This should be the accepted answer
            – Hennadii Madan
            Jun 13 '16 at 13:00












            I agree that this should be the accepted answer
            – Stefaan
            Jun 16 '16 at 20:24




            I agree that this should be the accepted answer
            – Stefaan
            Jun 16 '16 at 20:24












            A brilliant solution followed by good explanation by @kynan
            – Lyle
            Dec 3 '16 at 10:34




            A brilliant solution followed by good explanation by @kynan
            – Lyle
            Dec 3 '16 at 10:34












            great answer, thanks @weiz!
            – CanCeylan
            Feb 9 '17 at 21:06




            great answer, thanks @weiz!
            – CanCeylan
            Feb 9 '17 at 21:06










            up vote
            0
            down vote













            You can also add plt.show():



            plt.hist(OIR['Range'], bins, named=True, histtype='bar')
            plt.show()





            share|improve this answer



























              up vote
              0
              down vote













              You can also add plt.show():



              plt.hist(OIR['Range'], bins, named=True, histtype='bar')
              plt.show()





              share|improve this answer

























                up vote
                0
                down vote










                up vote
                0
                down vote









                You can also add plt.show():



                plt.hist(OIR['Range'], bins, named=True, histtype='bar')
                plt.show()





                share|improve this answer














                You can also add plt.show():



                plt.hist(OIR['Range'], bins, named=True, histtype='bar')
                plt.show()






                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Nov 22 at 11:40









                Suraj Rao

                22.4k75469




                22.4k75469










                answered Nov 22 at 11:36









                user3114859

                362




                362






























                    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%2f14506583%2fsuppress-output-of-object-when-plotting-in-ipython%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

                    Contact image not getting when fetch all contact list from iPhone by CNContact

                    count number of partitions of a set with n elements into k subsets

                    A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks