Guest User

Untitled

a guest
Feb 22nd, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. data = {datetime.date(2018, 1, 26): 1, datetime.date(2018, 1, 18): 1, datetime.date(2018, 1, 11): 4, datetime.date(2017, 12, 31): 2, datetime.date(2018, 1, 14): 1, datetime.date(2018, 1, 9): 2, datetime.date(2018, 1, 7): 1, datetime.date(2018, 1, 16): 2, datetime.date(2018, 1, 15): 2, datetime.date(2018, 1, 10): 1, datetime.date(2018, 1, 5): 1, datetime.date(2018, 1, 13): 3}
  2. dates = pd.date_range('2018-01-01', date.today())
  3. data = pd.Series(data=data)
  4. data = data.reindex(dates, fill_value=0)
  5. fig, ax = plt.subplots(figsize=(15, 7))
  6. data.plot(kind='bar', ax=ax)
  7. plt.xticks(rotation=45)
  8. plt.gca().xaxis.set_major_formatter(plt.FixedFormatter(data.index.to_series().dt.strftime("%b %d")))
  9.  
  10. data = <my dictionary>
  11. dates = pd.date_range('2018-01-01', date.today())
  12. data = pd.Series(data=data)
  13. data = data.fillna(0, inplace=True)
  14. fig, ax = plt.subplots(figsize=(15, 7))
  15. data.plot(kind='bar', ax=ax)
  16. plt.xticks(rotation=45)
  17. plt.gca().xaxis.set_major_formatter(plt.FixedFormatter(data.index.to_series().dt.strftime("%b %d")))
Add Comment
Please, Sign In to add comment