pathon画多条折线图(简介)
作者:互联网
目录
一、打开python
新建一个pathon项目。
二、代码
# -*- coding: utf-8 -*- import matplotlib.pyplot as plt names = ['1', '2', '3', '4', '5', '6'] x = range(len(names)) plt.rcParams['font.sans-serif'] = ['SimHei'] # 显示汉字 y_1 = [2, 3, 4, 5, 6, 1] y_2 = [3, 4, 5, 6, 1, 2] //y轴的值 y_3 = [4, 5, 6, 1, 2, 3] plt.plot(x, y_1, color='orangered', marker='o', linestyle='-', label='A') plt.plot(x, y_2, color='blueviolet', marker='D', linestyle='-.', label='B') plt.plot(x, y_3, color='green', marker='*', linestyle=':', label='C') plt.legend() # 显示图例 plt.xticks(x, names, rotation=45) plt.xlabel("X轴坐标") # X轴标签 plt.ylabel("Y轴坐标") # Y轴标签 plt.show()
三、运行结果
标签:pathon,plot,plt,color,简介,marker,names,折线图,linestyle 来源: https://blog.csdn.net/qq_42532598/article/details/112424755