在本文的示例中,python共享了绘制折线图的特定代码。 请作为参考。 具体内容如下
# encoding=utf-8
import matplotlib.pyplot as plt
来自py lab导入* #支持中文
mpl.rcparams [ ' font.sans-serif ' ]=[ ' simhei ' ]
names=['5'、' 10 '、' 15 '、' 20 '、' 25']
x=范围(len ) names ) )
y=[0.855、0.84、0.835、0.815、0.81]
y1=[0.86、0.85、0.853、0.849、0.83]
#PLT.plot(x,y,' ro-' ) )。
#PLT.plot(x,y1,' bo-' )。
# pl.xlim (-1,11 ) #限定横轴范围
# pl.ylim (-1,110 )限定纵轴范围
PLT.plot(x,y,marker='o ',mec='r ',mfc='w ',label=u'y=x^2图表) )
PLT.plot(x,y1,marker='* ',ms=10,label=u'y=x^3图表) )
PLT.legend(#启用图例
PLT.xticks(x,names,rotation=45 ) )。
是PLT.Margins(0)
PLT.subplots _ adjust (bottom=0.15 ) )。
PLT.xlabel(u'time ) s邻居) #X轴标签
PLT.ylabel(RMSE ) ) #Y轴标签
PLT.title(asimpleplot ) )标题
plt.show () )
效果图表:
希望以上是正文的全部内容,对大家的学习有帮助。 另外,我希望你支持很多编剧。