line plot

本文通过使用Matplotlib库创建了一组具有不同标记、颜色和线型的折线图,并展示了如何设置图表样式,包括背景颜色、轴脊颜色等。此外还介绍了如何保存图表到文件及显示图表。
import matplotlib.pyplot as plt
from numpy.random import randn
plt.style.use('ggplot')
plot_data1=randn(50).cumsum()
plot_data2=randn(50).cumsum()
plot_data3=randn(50).cumsum()
plot_data4=randn(50).cumsum()
fig=plt.figure(1,figsize=(10,8),facecolor="white")
ax=fig.add_subplot(1,1,1)
ax.spines["left"].set_color("white")
ax.spines["bottom"].set_color("white")
ax.plot(plot_data1,marker=r'o',markersize=4,markeredgecolor='black',color=u'blue',linestyle='-',label='Blue Solid')
ax.plot(plot_data2,marker=r'+',color=u'red',linestyle='--',label='Red Dash')
ax.plot(plot_data3,marker=r'*',color=u'green',linestyle='-.',label='Green Dash Dot')
ax.plot(plot_data4,marker=r's',color=u'orange',linestyle=':',label='Orange Dotted')
ax.xaxis.set_ticks_position('bottom')
ax.yaxis.set_ticks_position('left')
plt.title('Line Plots:Markers,Colors,and Linestyles')
plt.xlabel('Draw')
plt.ylabel('Random Number')
plt.legend(loc='best')
plt.grid()
plt.savefig('E:\python\慕课网 python\.idea\photo\line_plot.png',dpi=400,bbox_inches='tight')
plt.show()

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值