Skip to content

Small glitches on heatmaps #9831

Closed
Closed

Description

@markomanninen

Bug report

I found visible glitches on heatmaps on otherwise uniform data. Is it possible to outcome these by some setting and what causes them?

Code for reproduction

I'm using Seaborn API for the heatmap, but according to Seaborn developer it straightly uses matplotlib.

mwaskom/seaborn#1331

At the moment I have no exact matplotlib code for the reproduction, but I have Jupyter notebook document attached to see the whole code and several examples for the glitch.

In Seaborn API I use simply sns.heatmap and provide two dimentional data by coeftt function:

sns.heatmap(coeftt(range(1, 21), max))

Actual outcome

maxcoeffs21

There you can see couple of small squares in rows 3 and 4, columns 9 and 19.

Uniformness of the data should be visible in this screenshot, also reacheable on nb doc:

maxcoeffsd

Matplotlib version

  • Operating system: Windows 10
  • Matplotlib version: 2.1.0
  • Matplotlib backend (print(matplotlib.get_backend())): module://ipykernel.pylab.backend_inline
  • Python version: 3.6.2
  • Jupyter version (if applicable): packaged by conda-forge | (default, Jul 23 2017, 22:58:45) [MSC v.1900 64 bit (AMD64)]
  • Other libraries: Seaborn 0.8.1

Matplotlib was installed by anaconda, default channel, came together with packages in Seaborn.

MaxCoefficientonPolynomial.zip

Activity

  1. markomanninen commented on Nov 22, 2017

    @markomanninen
    Author

    Just an update, I got better results using purely matplotlib:

    import matplotlib.pyplot as plt
    plt.rcParams["axes.grid"] = False
    plt.imshow(coeftt(range(1, 21), max))
    plt.show()
    

    maxcoeffs

    so I guess I need to turn back to Seaborn support.

  2. tacaswell commented on Nov 23, 2017

    @tacaswell
    Member

    Are these glitches dependent on the size and dpi of the figure you are saving?

  3. added this to the milestone on Nov 23, 2017
  4. mwaskom commented on Nov 24, 2017

    @mwaskom

    Seems dependent on y axis inversion:

    f, ax = plt.subplots()
    ax.pcolormesh(coeftt(l, max))
    

    image

    f, ax = plt.subplots()
    ax.pcolormesh(coeftt(l, max))
    ax.invert_yaxis()
    

    image

  5. jklymak commented on Nov 24, 2017

    @jklymak
    Member

    On the macos backend I got this to show up once in a while. If you change the size of the figure, it goes away and comes back. Of course my dpi is 200, so it'd be harder to see than on a 120 dpi display.

    Here is a SSCCE to save the devs the bother of downloading a notebook file.

    import numpy as np
    import matplotlib.pyplot as plt
    
    def _coef(n):
        # 216 -> poly1d([2, 1, 6])
        return np.poly1d(list(map(int, str(n))))
    
    def coef(i, j, cb):
        return cb(_coef(i) * _coef(j)) + 1
    
    def coeft(l, cb):
        for i in l:
            mm = []
            for j in l:
                mm.append(coef(i, j, cb))
            yield mm
    
    def coeftt(l, cb):
        m = []
        for i in l:
            mm = []
            for j in l:
                mm.append(coef(i, j, cb))
            m.append(mm)
        return m
    
    xx = coeftt(range(1, 40), max)
    
    fig, ax = plt.subplots()
    ax.pcolormesh(xx)
    plt.show()
    
    fig, ax = plt.subplots()
    ax.pcolormesh(xx)
    ax.invert_yaxis()
    plt.show()
  6. github-actions commented on Apr 25, 2023

    @github-actions

    This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!

  7. tacaswell commented on Apr 25, 2023

    @tacaswell
    Member

    I can not reproduce this, but I only played around with it interactively.

  8. QuLogic commented on Apr 26, 2023

    @QuLogic
    Member

    I could reproduce in 2.0.0 with @jklymak's example, though I had to expand the window a little bit wider.

  9. QuLogic commented on Apr 26, 2023

    @QuLogic
    Member

    This was fixed by #16090.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions