python-3.x - 使用 matplotlib 在同一图形上绘制折线图
问题描述
我试图在同一个图上绘制两个折线图,但这些图是单独打印的。我过滤了数据并制作了两个折线图。如何在同一个图形上合并两个图形?
代码:
#getting columns with Primary type and arrest type
arrFalse=arrPri.loc[(arrPri["Primary Type"]== "ARSON") & (arrPri.Arrest == False),["count","Year"]]
arrTrue=arrPri.loc[(arrPri["Primary Type"]== "ARSON") & (arrPri.Arrest == True),["count","Year"]]
#plotting the graphs
arrFalse.plot(x="Year",y="count",kind="line",figsize=(10,5),color="red")
arrTrue.plot(x="Year",y="count",kind="line",figsize=(10,5),color="olive",linestyle="dashed")
plt.xlabel(uPri[i])
plt.legend(crimes.Arrest)
plt.title(uPri[i] + " Vs Crime count")
plt.show()
`
解决方案
推荐阅读
- mysql - Mysql如何从一个表中选择列值不是X和Y的所有记录
- angular - 在组件中使用动态服务
- tensorflow - 分别构建在 tensorflow API 和 keras API 上的两个代码块有什么不同?我的计算结果差距很大
- c# - Xamarin.Android 中断模式
- javascript - 错误:发布请求期间禁止跨域 null
- java - NotSibling:无效的约束
- matlab - 如何组合具有不同 x 轴和不同 y 轴的多个图
- gcc - 读取 GDTR 的值
- php - Symfony 4:由管理员注销活动用户
- java - 指定要从特定配置类注入的特定 bean