#25699·matplotlib

[Bug]: pcolormesh/pcolor doesn't show the image of an array of (M*1) OR (1*M) when providing X and Y explicitly

Author: chenyulueCreated Apr 16, 2023Updated Sep 27, 2026
Labelstopic: pcolor/pcolormeshkeep

Bug summary

pcolormesh/pcolor doesn't display the image of an array of size M*1 or 1*M when providing the parameters X and Y explicitly. If only the paramter C is provided, the two functions work well.

Code for reproduction

python
import matplotlib.pyplot as plt
import numpy as np

x, y = np.meshgrid([1,2], [1])
z = x + y

plt.pcolor(x, y, z) # or plt.pcolormesh(x, y, z), both of which give an empty figure.
plt.pcolor(z) # or plt.pcolormesh(z), both of which work well.

Actual outcome

plt.pcolor(x, y, z) gives an empty figure, while plt.pcolor(z) works as expected.

Expected outcome

Both of plt.pcolor(x, y, z) and plt.pcolor(z) should show the chart.

Additional information

No response

Operating system

Windows

Matplotlib Version

3.7.1

Matplotlib Backend

module://matplotlib_inline.backend_inline OR QtAgg

Python version

3.10.10

Jupyter version

3.6.3

Installation

conda