Closed
Description
plt.pcolormesh does not work any more with Numpy Masked Arrays, as of Matplotlib 2.1.0
import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(0,1,10)
xx, yy = np.meshgrid(x, x)
xx = np.ma.masked_array(xx, mask=xx>0.5)
yy = np.ma.masked_array(yy, mask=xx>0.5)
plt.pcolormesh(xx, yy, xx*yy)
produces the error
File "Miniconda3\lib\site-packages\matplotlib\pyplot.py", line 3167, in pcolormesh ret = ax.pcolormesh(*args, **kwargs)
File "Miniconda3\lib\site-packages\matplotlib\__init__.py", line 1710, in inner return func(ax, *args, **kwargs)
File "Miniconda3\lib\site-packages\matplotlib\axes\_axes.py", line 5636, in pcolormesh
coords = np.column_stack((X, Y)).astype(float, copy=False)
TypeError: astype() got an unexpected keyword argument 'copy'
The example works as expected without using Numpy Masked Arrays. And indeed one can check that the np.astype
does not accept the keyword copy
for Masked Arrays.
This problem seems related to #9577
Matplotlib version
- Operating system: Tested on both Windows and Ubuntu
- Matplotlib version: 2.1.0
- Matplotlib backend: Qt5Agg
- Python version: 3.6.3
- Matplotlib installed via Anaconda