Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Description
Bug summary
Data 0 cannot be plotted and the corresponding area in the the figure remains transparent, if some data is less than 0.
I tried to trace the problem and find that the reason seems to be a bug in ContourSet._get_lowers_and_uppers.(Line 1065 in contour.py(3.3.4))
if self.zmin == lowers[0]: # Include minimum values in lowest interval lowers = lowers.copy() # so we don't change self._levels if self.logscale: lowers[0] = 0.99 * self.zmin else: lowers[0] -= 1
while lowers[0] is the same as self.zmin, it will be reduced a little before using.
However, while lowers[0] is greater than self.zmin ( = -1.7E-13 ), it will not be reduced and remains as it is.
I think the condition should be revised to self.zmin <= lowers[0] from self.zmin == lowers[0].
Code for reproduction
importnumpyasnpimportmatplotlib.pyplotaspltdefmain():z0=np.array([[0.,0.,2.], [0.,0.,1.], [2.,1.,0.]])z1=np.array([[0.,0.,2.], [0.,0.,1.], [2.,1.,-1.7E-13]])fig=plt.figure(figsize=(2,4))ax0=fig.add_subplot(121)ax0.contourf(z0,cmap='jet')ax0.set_aspect('equal')ax1=fig.add_subplot(122)ax1.contourf(z1,cmap='jet')ax1.set_aspect('equal')plt.show()if__name__=="__main__":main()
Actual outcome
the left-bottom area in the right figure is not plotted and remains transparent,
just because the data z[2,2] is changed from 0 to -1.7E-13.
Expected outcome
The figure in the right site is expected to be the same as the left one.
Operating system
Windows 10
Matplotlib Version
3.3.4
Matplotlib Backend
module://ipykernel.pylab.backend_inline
Python version
3.8.8
Jupyter version
6.0.1
Other libraries
No response
Installation
conda
Conda channel
No response