# 画柱状图
plt.bar(x_labels, grid)
画折线图
"""
for i in range(len(grid)-1):
plt.plot([x_labels[i],x_labels[i+1]],[grid[i],grid[i]],color = 'b')
plt.plot([x_labels[i],x_labels[i]],[0,grid[i]],'--',color = 'b')
plt.plot([x_labels[i+1],x_labels[i+1]],[0,grid[i]],'--',color = 'b')
"""
公共部分
plt.xlabel('x_labels')
plt.ylabel('y_labels')
plt.title("Plotting in Python demonstration")
plt.show()
本文详细介绍如何使用Python的matplotlib库绘制柱状图和折线图,包括设置x轴和y轴标签,图表标题,并展示数据可视化的基本操作。
1万+

被折叠的 条评论
为什么被折叠?



