python - pyplot 绘制不同形状的图

标签 python matplotlib plot shapes

我特别想让其中一行比另一行早结束。它们是按时间顺序排列的(逐月和逐年)。

months= [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]
pass_2015 = [0, 0, 0, 0, 0, 134, 115, 185, 179, 147, 160, 126, 208, 48, 47, 50]
pass_2017 = [34, 106, 98, 162, 128, 166, 117, 123, 225, 161, 110, 100, 144, 53, 27, 10]
pass_2019 = [141,175,166,227,302,302,314]
plt.plot(months, pass_2015, color='gray')
plt.plot(months, pass_2017, color='green')
plt.plot(months, pass_2019, color='blue')

最佳答案

import matplotlib.pyplot as plt
months= [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]
pass_2015 = [0, 0, 0, 0, 0, 134, 115, 185, 179, 147, 160, 126, 208, 48, 47, 50]
pass_2017 = [34, 106, 98, 162, 128, 166, 117, 123, 225, 161, 110, 100, 144, 53, 27, 10]
pass_2019 = [141,175,166,227,302,302,314]
plt.plot(months, pass_2015, color='gray')
plt.plot(months, pass_2017, color='green')
plt.plot(months[:len(pass_2019)], pass_2019, color='blue')
plt.show()

enter image description here

关于python - pyplot 绘制不同形状的图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53220678/

相关文章:

python - 在python中的一个图中叠加热图

numpy - 如何为我的 AWS Elastic Beanstalk 应用程序安装 matplotlib?

python - 为图表添加副标题

python - Bokeh 绘图 : 'NoneType' object has no attribute 'line'

python - 自定义模型 app_label 不适用于 django 1.4?

Python 列表元素交换未按预期工作

python - 我应该如何缩短这行 Python 代码?

python - Matplotlib:图形左边缘和 y 轴之间的固定间距

r - 如何在 R 中的 "y"轴的两侧绘制(几乎)相同的函数?

python - 用户警告 : Failed to initialize NumPy: module compiled against API version 0xf but this version of numpy is 0xe (Triggered internally at