python - 在单个网格中重叠 pyplot.imshow() 图
问题描述
我想绘制这些数字。对于第一张图:
对于代码片段:
import matplotlib.pyplot as plt
row = 30
col = row
areas_pher = [[-0.01 for i in range(col)] for j in range(row)]
for i in range(1, row-1):
for j in range(1, col-1):
areas_pher[i][j] = 0
max_pher = 20
for pher in range(1, col-1):
areas_pher[15][pher] = max_pher * pher/max_pher
plt.imshow(areas_pher, cmap="Blues_r", vmin=0, vmax=max_pher)
第二个图:
对于代码片段:
import matplotlib.pyplot as plt
import numpy as np
areas_ant = [[6 for i in range(col)] for j in range(row)]
prob_ant = 0.05
for i in range(1, row-1):
for j in range(1, col-1):
rand = np.random.rand()
if rand < prob_ant:
areas_ant[i][j] = 5
plt.imshow(areas_ant, cmap="Blues")
我的问题是,让它的数字重叠的最佳方法是什么,如下图所示?
解决方案
推荐阅读
- javascript - 我必须单击汉堡栏导航两次才能触发事件侦听器
- css - Asp.net core mvc 2.0 - bootstrap.css 未发布
- excel - 如果语句返回太多值
- c# - Raycast 无缘无故返回 null
- angular - Angular 的路由守卫没有在应用程序中运行
- css - 为什么 Position Fixed 表现得像 Position Absolute
- python - 如何制作没有标题栏的选项卡窗格?
- web-component - 如何使用 vue-cli 创建 Web 组件
- amazon-web-services - AWS CloudFormation 用户数据 EC2 环境变量
- php - 将音频上传到服务器 PHP android