FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Getting internal "MatplotlibDeprecationWarning: shading='flat' ..." · Issue #18595 · matplotlib/matplotlib · GitHub

Repository navigation

Getting internal "MatplotlibDeprecationWarning: shading='flat' ..." #18595

Closed

Description

Bug report

Bug summary

I'm getting this warning:

MatplotlibDeprecationWarning: shading='flat' when X and Y have the same dimensions as C is deprecated since 3.3.  Either specify the corners of the quadrilaterals with X and Y, or pass shading='auto', 'nearest' or 'gouraud', or set rcParams['pcolor.shading'].  This will become an error two minor releases later.

Code for reproduction

import numpy as np
import matplotlib.pyplot as plt

x = np.arange(10.0)
mat = np.random.randn(10, 10)
plt.contour(x, x, mat)

# for a solid colorbar:
cbar = plt.colorbar()
cbar.filled = True
cbar.draw_all()

Actual outcome

Python 3.8.5 (default, Sep  4 2020, 07:30:14)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.18.1 -- An enhanced Interactive Python. Type '?' for help.

In [1]: run ttt
ttt.py:11: MatplotlibDeprecationWarning: shading='flat' when X and Y have the same dimensions as C is deprecated since 3.3.  Either specify the corners of the quadrilaterals with X and Y, or pass shading='auto', 'nearest' or 'gouraud', or set rcParams['pcolor.shading'].  This will become an error two minor releases later.
  cbar.draw_all()

In [2]: import matplotlib

In [3]: matplotlib.__version__
Out[3]: '3.3.1'

In [4]: quit

Expected outcome

No deprecation warning.

Matplotlib version

  • Operating system: Linux 5.3.0-64-generic Include test_text in default_test_modules #58-Ubuntu
  • Matplotlib version: 3.3.1 (I also tried 3.3.2 -- same result)
  • Matplotlib backend (print(matplotlib.get_backend())): Qt5Agg
  • Python version: 3.8.5
  • Jupyter version (if applicable):
  • Other libraries:

Matplotlib installed via conda, default channel.

Activity

  1. ksunden commented on Sep 27, 2020

    Member

    col = self.ax.pcolormesh(*args, **kw, shading='flat')

    Here is the offending line

  2. added this to the v3.3.3 milestone on Sep 28, 2020
  3. jklymak commented on Sep 28, 2020

    Member

    This shouldn't be too hard to fix - someone just needs to look and see how the solid colorbar is made and make the x/y the proper length....

  4. jklymak commented on Sep 28, 2020

    Member

    OK, so its easy to fix the above to the old behaviour. However, I strongly expect the old behaviour was incorrect and dropping the color for your highest contour value. Is that OK? Your last color was basically the color of the second to last contour.

  5. dopplershift commented on Sep 28, 2020

    Contributor

    Well, that's ok because it matches the case with filled=False. My question would be, why does this code:

    import numpy as np
    import matplotlib.pyplot as plt
    
    x = np.arange(10.0)
    mat = np.hypot(x, x[:, None])
    plt.xlim(-1, 10)
    plt.ylim(-1, 10)
    
    cntr = plt.contour(x, x, mat, levels=np.arange(13) + 0.5)
    
    # for a solid colorbar:
    cbar = plt.colorbar()
    #cbar.filled = True
    cbar.draw_all()

    produce:

    which only has 12 lines on the colorbar (and thus is already chopping the highest level).

  6. jklymak commented on Sep 28, 2020

    Member

    Is that just clipping?

  7. dopplershift commented on Sep 28, 2020

    Contributor

    Probably: len(cbar.lines[0].get_colors()) gives 13. If only I could get it to draw properly...I can never remember how to hack colorbar axes...

  8. jklymak commented on Sep 28, 2020

    Member

    hmmmm, are the contour axes still the old style? Because the new style should allow just setting the xlim....

  9. dopplershift commented on Sep 28, 2020

    Contributor

    Setting xlim/ylim on the colorbar only changes its size, it doesn't draw anything above 12.5 for me.

  10. jklymak commented on Sep 28, 2020

    Member

    Yech. Curious if it ever worked or if we (prob. me) broke something?

  11. anntzer commented on Oct 5, 2020

    Contributor

    My guess is that this comes from

    self.outline.set_xy(xy)

    i.e. the outline doesn't get updated when you change the axis limits. I think the outline (and patch) should instead be defined in ax.transAxes for things to work?

  12. jklymak commented on Oct 28, 2020

    Member

    Oh hum. I spent about a week of Matplotlib time working on fixing all this, but its a pretty big architecture change. Someone should probably dive in and patch this for the contour case cited above for 3.3.3

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL