这篇文章主要介绍了python怎么利用scatter绘画散点图的相关知识,内容详细易懂,操作简单快捷,具有一定借鉴价值,相信大家阅读完这篇python怎么利用scatter绘画散点图文章都会有所收获,下面我们一起来看看吧。
scatter绘画散点图代码如下:
import matplotlib.pyplot as pltplt.scatter(x,y, s = 20 c='b' marker=‘o' cmap=None, norm=None, vmin=None, vmax=None, alpha=None, linewidths=None,)
import numpy as npimport pandas as pdimport matplotlib.pyplot as plt x=np.random.randint(0,10,10)y=np.random.randint(0,10,10)print(x)print(y)plt.scatter(x,y,s=50)默认形状圆点,颜色b 蓝色,大小50
out:
[5 1 5 3 1 5 0 5 4 7]
[8 2 7 7 8 6 3 8 5 9]
import numpy as npimport pandas as pdimport matplotlib.pyplot as pltx = np.array([[0,0],[0,1],[1,1],[3,2],[-2,3],[1,2],[4,3]])print(x)plt.scatter(x[:,0],x[:,1],marker='x',color='k',s=20)#点的形状x,颜色黑色,大小20
out:
[[ 0 0]
[ 0 1]
[ 1 1]
[ 3 2]
[-2 3]
[ 1 2]
[ 4 3]]
关于“python怎么利用scatter绘画散点图”这篇文章的内容就介绍到这里,感谢各位的阅读!相信大家对“python怎么利用scatter绘画散点图”知识都有一定的了解,大家如果还想学习更多知识,欢迎关注编程网行业资讯频道。