在matplotlib中制作散点图,在x轴上显示日期,在y上显示值 [英] Make a Scatter Plot in matplotlib with dates on x axis and values on y

查看:215
本文介绍了在matplotlib中制作散点图,在x轴上显示日期,在y上显示值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在制作具有日期数组和一堆PM 2.5值的散点图时遇到了麻烦.我的列表如下所示:

I am having trouble making a scatter plot that has from a date array and a bunch of PM 2.5 values. My lists would look like the following:

dates = ['2015-12-20','2015-09-12']  
PM_25 = [80, 55]

推荐答案

import pandas as pd
dates = ['2015-12-20','2015-09-12']  
PM_25 = [80, 55]
dates = [pd.to_datetime(d) for d in dates]

plt.scatter(dates, PM_25, s =100, c = 'red')

s设置大小 c设置颜色

还有很多其他参数: http://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.scatter

There are a whole bunch of other args as well: http://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.scatter

这篇关于在matplotlib中制作散点图,在x轴上显示日期,在y上显示值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆