making seaborn heatmap from DataFrame plot to be aware of data rangesMaking heatmap from pandas DataFrameDelete column from pandas DataFrame by column nameSelect rows from a DataFrame based on values in a column in pandasHow to make IPython notebook matplotlib plot inlineGet list from pandas DataFrame column headersSeaborn plots not showing upHow to save a Seaborn plot into a fileUsing matplotlib *without* TCLTypeError when plotting heatmap with seabornmatplotlib implot not showing correct axis values when plotting pandas dataframe, seaborn shows correct axis values but doesn't show x and y on figure

How can I raise concerns with a new DM about XP splitting?

Stereotypical names

Can I create an upright 7-foot × 5-foot wall with the Minor Illusion spell?

What (else) happened July 1st 1858 in London?

Why are on-board computers allowed to change controls without notifying the pilots?

Can I Retrieve Email Addresses from BCC?

Is there an Impartial Brexit Deal comparison site?

Simulating a probability of 1 of 2^N with less than N random bits

Why does this part of the Space Shuttle launch pad seem to be floating in air?

Calculating the number of days between 2 dates in Excel

Is the next prime number always the next number divisible by the current prime number, except for any numbers previously divisible by primes?

Partial sums of primes

How can I successfully establish a nationwide combat training program for a large country?

Is infinity mathematically observable?

Latex for-and in equation

Pronouncing Homer as in modern Greek

Are Warlocks Arcane or Divine?

I'm in charge of equipment buying but no one's ever happy with what I choose. How to fix this?

How to interpret the phrase "t’en a fait voir à toi"?

Proof of Lemma: Every integer can be written as a product of primes

Can I rely on these GitHub repository files?

Reply ‘no position’ while the job posting is still there (‘HiWi’ position in Germany)

node command while defining a coordinate in TikZ

Is there a problem with hiding "forgot password" until it's needed?



making seaborn heatmap from DataFrame plot to be aware of data ranges


Making heatmap from pandas DataFrameDelete column from pandas DataFrame by column nameSelect rows from a DataFrame based on values in a column in pandasHow to make IPython notebook matplotlib plot inlineGet list from pandas DataFrame column headersSeaborn plots not showing upHow to save a Seaborn plot into a fileUsing matplotlib *without* TCLTypeError when plotting heatmap with seabornmatplotlib implot not showing correct axis values when plotting pandas dataframe, seaborn shows correct axis values but doesn't show x and y on figure













0















How can one make seaborn heatmap (created from a pandas DataFrame plot) to be aware of the data ranges? I.e. when I hover the mouse pointer over the plot, I can see in the bottom right corner of the plot window "x= y=", while I want to see coordinates of the point on the plot I am hovering over (for example, "x=25.6, y=3.3"), assuming, of course, that the input DataFrame contains a 2D histogram with equal size bins along each axis.



Alternatively, maybe I could create such plot in a different way to achieve the same effect? For example, with ax.hist2d I get it out of the box, but I want to be able to compute with custom code content of each bin and make it effectively a heatmap plot (with color coding of the bin contents).



import numpy as np 
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
Index = [ 1.0, 2.0, 3.0, 4.0, 5.0]
Cols = [10.0, 20.0, 30.0, 40.0, 50.0]
df = pd.DataFrame(abs(np.random.randn(5, 5)),
index=Index, columns=Cols)
plt.close(1)
fig,ax = plt.subplots(num=1)
sns.heatmap(df, annot=True)
plt.show(block=False)


Thank you for your help!










share|improve this question


























    0















    How can one make seaborn heatmap (created from a pandas DataFrame plot) to be aware of the data ranges? I.e. when I hover the mouse pointer over the plot, I can see in the bottom right corner of the plot window "x= y=", while I want to see coordinates of the point on the plot I am hovering over (for example, "x=25.6, y=3.3"), assuming, of course, that the input DataFrame contains a 2D histogram with equal size bins along each axis.



    Alternatively, maybe I could create such plot in a different way to achieve the same effect? For example, with ax.hist2d I get it out of the box, but I want to be able to compute with custom code content of each bin and make it effectively a heatmap plot (with color coding of the bin contents).



    import numpy as np 
    import pandas as pd
    import seaborn as sns
    import matplotlib.pyplot as plt
    Index = [ 1.0, 2.0, 3.0, 4.0, 5.0]
    Cols = [10.0, 20.0, 30.0, 40.0, 50.0]
    df = pd.DataFrame(abs(np.random.randn(5, 5)),
    index=Index, columns=Cols)
    plt.close(1)
    fig,ax = plt.subplots(num=1)
    sns.heatmap(df, annot=True)
    plt.show(block=False)


    Thank you for your help!










    share|improve this question
























      0












      0








      0


      1






      How can one make seaborn heatmap (created from a pandas DataFrame plot) to be aware of the data ranges? I.e. when I hover the mouse pointer over the plot, I can see in the bottom right corner of the plot window "x= y=", while I want to see coordinates of the point on the plot I am hovering over (for example, "x=25.6, y=3.3"), assuming, of course, that the input DataFrame contains a 2D histogram with equal size bins along each axis.



      Alternatively, maybe I could create such plot in a different way to achieve the same effect? For example, with ax.hist2d I get it out of the box, but I want to be able to compute with custom code content of each bin and make it effectively a heatmap plot (with color coding of the bin contents).



      import numpy as np 
      import pandas as pd
      import seaborn as sns
      import matplotlib.pyplot as plt
      Index = [ 1.0, 2.0, 3.0, 4.0, 5.0]
      Cols = [10.0, 20.0, 30.0, 40.0, 50.0]
      df = pd.DataFrame(abs(np.random.randn(5, 5)),
      index=Index, columns=Cols)
      plt.close(1)
      fig,ax = plt.subplots(num=1)
      sns.heatmap(df, annot=True)
      plt.show(block=False)


      Thank you for your help!










      share|improve this question














      How can one make seaborn heatmap (created from a pandas DataFrame plot) to be aware of the data ranges? I.e. when I hover the mouse pointer over the plot, I can see in the bottom right corner of the plot window "x= y=", while I want to see coordinates of the point on the plot I am hovering over (for example, "x=25.6, y=3.3"), assuming, of course, that the input DataFrame contains a 2D histogram with equal size bins along each axis.



      Alternatively, maybe I could create such plot in a different way to achieve the same effect? For example, with ax.hist2d I get it out of the box, but I want to be able to compute with custom code content of each bin and make it effectively a heatmap plot (with color coding of the bin contents).



      import numpy as np 
      import pandas as pd
      import seaborn as sns
      import matplotlib.pyplot as plt
      Index = [ 1.0, 2.0, 3.0, 4.0, 5.0]
      Cols = [10.0, 20.0, 30.0, 40.0, 50.0]
      df = pd.DataFrame(abs(np.random.randn(5, 5)),
      index=Index, columns=Cols)
      plt.close(1)
      fig,ax = plt.subplots(num=1)
      sns.heatmap(df, annot=True)
      plt.show(block=False)


      Thank you for your help!







      pandas matplotlib plot seaborn heatmap






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 21 at 14:38









      S.VS.V

      1809




      1809






















          1 Answer
          1






          active

          oldest

          votes


















          1














          If you replace sns.heatmap(...) by ax.imshow(..), you're close to what you need. You can then set the extent of the image to the data range you need.



          import numpy as np; np.random.seed(42)
          import pandas as pd
          import matplotlib.pyplot as plt

          Index = [ 1.0, 2.0, 3.0, 4.0, 5.0]
          Cols = [10.0, 20.0, 30.0, 40.0, 50.0]
          df = pd.DataFrame(abs(np.random.randn(5, 5)),
          index=Index, columns=Cols)
          plt.close(1)
          fig,ax = plt.subplots(num=1)
          dx = np.diff(df.columns)[0]/2
          dy = np.diff(df.index)[0]/2
          extent = [df.columns.min()-dx, df.columns.max()+dx,
          df.index.min()-dy, df.index.max()+dy]
          ax.imshow(df, extent=extent, aspect="auto")

          plt.show()


          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%2f55282940%2fmaking-seaborn-heatmap-from-dataframe-plot-to-be-aware-of-data-ranges%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














            If you replace sns.heatmap(...) by ax.imshow(..), you're close to what you need. You can then set the extent of the image to the data range you need.



            import numpy as np; np.random.seed(42)
            import pandas as pd
            import matplotlib.pyplot as plt

            Index = [ 1.0, 2.0, 3.0, 4.0, 5.0]
            Cols = [10.0, 20.0, 30.0, 40.0, 50.0]
            df = pd.DataFrame(abs(np.random.randn(5, 5)),
            index=Index, columns=Cols)
            plt.close(1)
            fig,ax = plt.subplots(num=1)
            dx = np.diff(df.columns)[0]/2
            dy = np.diff(df.index)[0]/2
            extent = [df.columns.min()-dx, df.columns.max()+dx,
            df.index.min()-dy, df.index.max()+dy]
            ax.imshow(df, extent=extent, aspect="auto")

            plt.show()


            enter image description here






            share|improve this answer



























              1














              If you replace sns.heatmap(...) by ax.imshow(..), you're close to what you need. You can then set the extent of the image to the data range you need.



              import numpy as np; np.random.seed(42)
              import pandas as pd
              import matplotlib.pyplot as plt

              Index = [ 1.0, 2.0, 3.0, 4.0, 5.0]
              Cols = [10.0, 20.0, 30.0, 40.0, 50.0]
              df = pd.DataFrame(abs(np.random.randn(5, 5)),
              index=Index, columns=Cols)
              plt.close(1)
              fig,ax = plt.subplots(num=1)
              dx = np.diff(df.columns)[0]/2
              dy = np.diff(df.index)[0]/2
              extent = [df.columns.min()-dx, df.columns.max()+dx,
              df.index.min()-dy, df.index.max()+dy]
              ax.imshow(df, extent=extent, aspect="auto")

              plt.show()


              enter image description here






              share|improve this answer

























                1












                1








                1







                If you replace sns.heatmap(...) by ax.imshow(..), you're close to what you need. You can then set the extent of the image to the data range you need.



                import numpy as np; np.random.seed(42)
                import pandas as pd
                import matplotlib.pyplot as plt

                Index = [ 1.0, 2.0, 3.0, 4.0, 5.0]
                Cols = [10.0, 20.0, 30.0, 40.0, 50.0]
                df = pd.DataFrame(abs(np.random.randn(5, 5)),
                index=Index, columns=Cols)
                plt.close(1)
                fig,ax = plt.subplots(num=1)
                dx = np.diff(df.columns)[0]/2
                dy = np.diff(df.index)[0]/2
                extent = [df.columns.min()-dx, df.columns.max()+dx,
                df.index.min()-dy, df.index.max()+dy]
                ax.imshow(df, extent=extent, aspect="auto")

                plt.show()


                enter image description here






                share|improve this answer













                If you replace sns.heatmap(...) by ax.imshow(..), you're close to what you need. You can then set the extent of the image to the data range you need.



                import numpy as np; np.random.seed(42)
                import pandas as pd
                import matplotlib.pyplot as plt

                Index = [ 1.0, 2.0, 3.0, 4.0, 5.0]
                Cols = [10.0, 20.0, 30.0, 40.0, 50.0]
                df = pd.DataFrame(abs(np.random.randn(5, 5)),
                index=Index, columns=Cols)
                plt.close(1)
                fig,ax = plt.subplots(num=1)
                dx = np.diff(df.columns)[0]/2
                dy = np.diff(df.index)[0]/2
                extent = [df.columns.min()-dx, df.columns.max()+dx,
                df.index.min()-dy, df.index.max()+dy]
                ax.imshow(df, extent=extent, aspect="auto")

                plt.show()


                enter image description here







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Mar 21 at 15:37









                ImportanceOfBeingErnestImportanceOfBeingErnest

                139k13161239




                139k13161239





























                    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%2f55282940%2fmaking-seaborn-heatmap-from-dataframe-plot-to-be-aware-of-data-ranges%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

                    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

                    용인 삼성생명 블루밍스 목차 통계 역대 감독 선수단 응원단 경기장 같이 보기 외부 링크 둘러보기 메뉴samsungblueminx.comeh선수 명단용인 삼성생명 블루밍스용인 삼성생명 블루밍스ehsamsungblueminx.comeheheheh

                    155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해