首页 > 编程知识 正文

python基础教程廖雪峰,Python画散点图

时间:2023-05-04 19:01:33 阅读:9178 作者:4344

完成本教程后,大多数情况下,您可以绘制条形图。

声明:

需要Python列表知识的教程matplotlib库散点图使用所需的库#与要使用的库文件import numpy as np #数组相关的库import matplotlib.pyplot as plt #数组出图的散点图n=10x=NP.random.rand(n )包含10个均匀分布的随机值的横坐标数组,大小为[ 0,1 ] y=NP.random.random

调整散布点大小n=10x=NP.random.rand(n ) y=np.random.rand(N ) n ) area=np.random.rand(N ) n ) 1000#为10个大小为1000 ) fig=PLT.figure(ax=PLT.subplot ) ax.scatter(x ) x,y,s=area,alpha=0.5 ) #绘制散点图,面积随机的PLT

散布颜色n=10x=NP.random.rand(n ) y=np.random.rand(N ) n ) x2=np.random.rand(N ) n ) y2=NP.random.rand

调整散点形状n=10x=NP.random.rand(n ) y=np.random.rand(N ) n ) x2=np.random.rand(N ) n ) y2=NP.random . 1000fig=plt.figure ) ax=plt.subplot ) ax.scatter(x ) x,y,s=area,alpha=alpha=0.6 ) ax.Scatter(x3,)

在这里说明的话,您可能注意到照片中的红色倒三角,面积越大的颜色越红。 这是因为在ax.scatter ()中启用了参数cmap,所以必须与控制颜色的参数3358www.Sina.com/一起使用。 cmap表示调色板类型,c表示颜色深浅。

显示调色板的类型。 matplotlib官网说明

散布边界n=10x=[1] y=[1] x2=[ 1.1 ] y2=[ 1.1 ] x3=[ 0.9 ] y3=[ 0.9 ] area=[ 20000 ] fig=PLT.figure ) ) ax=

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。