- 积分
- 290
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2023-3-24
- 最后登录
- 1970-1-1
|
发表于 2023-3-26 18:30:44
|
显示全部楼层
 - import numpy as np
- import matplotlib.pyplot as plt
- n = 20
- sig = np.ma.masked_greater(np.random.rand(n, n), 0.25)
- f, ax1 = plt.subplots(1, 1, figsize=(4, 4))
- # Find indices of non-masked elements
- y, x = np.where(~sig.mask)
- # Plot circles using scatter
- ax1.scatter(x, y, s=100, facecolors='none', edgecolors='black', linewidth=1)
- # Invert the y-axis to match pcolor orientation
- ax1.invert_yaxis()
- # Set x and y axis limits
- ax1.set_xlim(-0.5, n - 0.5)
- ax1.set_ylim(-0.5, n - 0.5)
- # Show the grid lines in specified color
- # ax1.grid(True, linewidth=0.5, color="black")
- # Set x and y ticks
- ax1.set_xticks(np.arange(0, n, 1))
- ax1.set_yticks(np.arange(0, n, 1))
- plt.show()
这样可能能解决问题 |
|