python - How to keep x and y-axis equal with a colorbar?
问题描述
I have been able to use scatter
to plot x
, y
, and z
, with the latter being the color-coded variables defined by a colorbar
. However, whenever I introduce the colorbar
it affects the aspect-ratio of the axes in the sense that it "steals space" from the x-axis. Even if I define the figsize
.
cm = plt.cm.get_cmap('viridis')
fig, ax = plt.subplots(figsize=[6, 6])
for dat_x, dat_b, dat_c in zip([data_x1, data_x2, data_x3], [data_y1, data_y2, data_y3], [data_z1, data_z2, data_z3]):
for dx, dy, dz in zip(dat_x, dat_b, dat_c):
sc = ax.scatter(dx, dy, dz, cmap=cm, norm=mplcol.LogNorm(vmin=1, vmax=200, s=100)
sc = plt.colorbar(sc)
plt.show()
How can I keep the length of the x-axis and the y-axis equal while simultaneously prevent the colorbar
from "stealing space" from the x-axis?
解决方案
推荐阅读
- powerbi - Power BI:如何计算源表中值的出现?
- python - 如何使用 Div 和 Script 标签在 HTML 中渲染两个或多个散景图?
- react-native - Webview&redabilitywebview 在 android 中工作正常而不是在 ios 中反应原生
- heroku - Heroku 自动对我的数据库进行维护,现在我的应用程序无法连接
- python - 使用 OpenCV 和 Python 提取楼层布局和阈值
- git - Git ignore ignoring too many things
- selenium - 如果元素在硒的 IF 中不可见,如何移动到 ELSE 条件
- asp.net - Onclick 图像按钮不起作用 Asp.net 网格视图
- java - Java将值添加到指向另一个ArrayList中的值的ArrayList
- openlayers - Openlayers 在同一位置有一些标记聚集