Matplotlib散点图大小图例

您所在的位置:网站首页 matplotlib调整图例大小 Matplotlib散点图大小图例

Matplotlib散点图大小图例

#Matplotlib散点图大小图例| 来源: 网络整理| 查看: 265

下面是使用matplotlib的scatterplot生成附加图像的少量代码。 Output image from code.Matplotlib散点图大小图例

我想获得一个显示几个点的大小和相应的“z值”的“图例”。

自己建造它的缺点,有没有像这样的东西?与颜色条相似的“尺寸”?

import matplotlib.pyplot as plt import numpy as np fig = plt.figure(figsize=(8,6)) inset = fig.add_subplot(111) np.random.seed(0) # so the image is reproducible x1 = np.random.rand(30) y1 = np.random.rand(30) z1 = np.random.rand(30) axis = inset.scatter(x1,y1,s=z1*100,c=z1,vmin=0,vmax=1) inset.set_xlabel("X axis") inset.set_ylabel("Y axis") cbar = fig.colorbar(axis,ticks=[0,0.5,1]) cbar.ax.set_yticklabels(["Low","Medium","High"]) plt.savefig('scatterplot-zscale.png',bbox_inches='tight')

来源

2017-04-03 John Pretz



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3