Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

Closed
@twmacro

Description

@twmacro

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions