matplotlib

import numpy as np

import matplotlib.pyplot as plt

#准备数据
ypoints=np.array([5,10,15,20,25,30,25,20,15,10,5])
ypoints2=np.array([5,5,5,5,5,5,5,5,5,5,5])

#数据放进图表
#plt.plot(ypoints,'o:g')
#plt.plot(ypoints,marker='o',linestyle=':',color='y')
plt.plot(ypoints,marker='o',ls=':',c='g',linewidth='1')
plt.plot(ypoints2,marker='o',ls=':',c='r',linewidth='1')
#添加标题x轴名字,y轴名字
plt.title("table")
plt.xlabel('x-label')
plt.ylabel('y-label')

#添加网格
plt.grid()
#显示
plt.show()
import numpy as np
import matplotlib.pyplot as plt

x = np.array([1,2,3,4,5,6,7,8,9,10])
y = np.array([2,8,6,8,10,9,6,6,8,2])
sizes=np.array([10,20,30,40,50,60,70,80,90,100])
colors=np.array(["red","green","black","orange","purple","beige","cyan","magenta","red","orange"])
#scatter 方法散点图
plt.scatter(x,y, s=sizes , c=colors)
plt.show()

import numpy as np
import matplotlib.pyplot as plt
#随即生成1----50个数据
x=np.random.rand(50)
y=np.random.rand(50)
plt.scatter(x,y,color='hotpink')

#随即生成1----50个数据
x2=np.random.rand(50)
y3=np.random.rand(50)
plt.scatter(x,y,color='red')

plt.show()

Original: https://blog.csdn.net/weixin_59862023/article/details/124571441
Author: 大数据技术李建波
Title: matplotlib

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/764986/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

亲爱的 Coder【最近整理,可免费获取】👉 最新必读书单  | 👏 面试题下载  | 🌎 免费的AI知识星球