欢迎随缘关注@pythonic生物人
折线图中常用参数
详细参数
官网资料:https://matplotlib.org/api/_as_gen/matplotlib.pyplot.plot.html
import math import matplotlib.pyplot as plt plt.figure(dpi=120) plt.plot(range(2,10),#x轴方向变量 [math.sin(i) for i in range(2,10)],#y轴方向变量 linestyle='--',#线型 linewidth=2,#线宽 color='red',#线和marker的颜色,当markeredgecolor markerfacecolor有设定时,仅仅控制line颜色 ##marker的特性设置 marker='^',#marker形状 markersize='15',#marker大小 markeredgecolor='green',#marker外框颜色 markeredgewidth=2, #marker外框宽度 markerfacecolor='red',#marker填充色 fillstyle='top',#marker填充形式,可选{'full', 'left', 'right', 'bottom', 'top', 'none'} markerfacecoloralt='blue',#marker未被填充部分颜色 markevery=2,#每隔一个画一个marker label='sin(x)',#图例 alpha=0.3,#线和marker的透明度 ) ##下面两条线使用默认参数绘制 plt.plot(range(2,10),[math.cos(i) for i in range(2,10)],label='cos(x)') plt.plot(range(2,10),[2*math.cos(i)+1 for i in range(2,10)],label='2*cos(x)+1') plt.legend()#绘制图例 plt.xlabel('x') plt.ylabel('f(x)')欢迎随缘关注@pythonic生物人