python - 如何使用 Gridspec 为我的所有子图绘制一个颜色条?
问题描述
我正在尝试为我拥有的所有子批次绘制一个颜色条(范围:0,最大值)。我在这里尝试了Matplotlib 2 Subplots, 1 Colorbar的解决方案,但它们需要使用我没有使用的 plt.subplots。
这是我当前的代码,它显示 3 个单独的颜色条。
fig = plt.figure(figsize=(15,15))
G = gridspec.GridSpec(2, 2)
#Haut
top = plt.subplot(G[0,0], projection='polar')
phi2D_grid, rho2D_grid = np.meshgrid(phi_grid, rho_grid)
plt.pcolormesh(phi2D_grid, rho2D_grid, compteur_top, cmap='jet', vmin=0, vmax=max)
plt.colorbar()
#Côtés
lat = plt.subplot(G[1,:])
phi2D_grid, z2D_grid = np.meshgrid(phi_grid, z_grid)
plt.pcolormesh(phi2D_grid, z2D_grid, compteur_lat, cmap='jet', vmin=0, vmax=max)
plt.colorbar()
#Bas
bot = plt.subplot(G[0, 1], projection='polar')
phi2D_grid, rho2D_grid = np.meshgrid(phi_grid, rho_grid)
plt.pcolormesh(phi2D_grid, rho2D_grid, compteur_bot, cmap='jet', vmin=0, vmax=max)
plt.colorbar()
我想我确实需要在这里使用 Gridspec ,因为我需要按如下方式显示我的数字:
解决方案
推荐阅读
- django - 如何使 Django FormSet 接受 m2m 但将它们存储为多个 FK 记录?
- python-3.x - 当 bigquery 的查询结果为空(使用 pthon)时,关于如何使用 gcp stackdriver 收集日志的任何想法?
- rust - 如何检查宏规则中的 arg 类型?
- c++ - 当其他链接库将 stdc++ 链接为动态时,如何将 libstdc++ 链接设置为静态?
- python - 如何在 DataFrame 内的字符串中添加换行符?
- asp.net-mvc - 在 Visual Studio 安装程序的什么位置可以找到 BuildTools 组件?
- php - Symfony 4 - 如何在控制器中验证我的令牌?
- javascript - 通过 onSubmit 在 React 中更改表单的 CSS 样式
- python - Python 在使用多处理和 itertools 时传递多个值
- python - 为什么这个正则表达式匹配这个?