Advertisement
Guest User

Untitled

a guest
Jul 16th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. import pandas as pd
  2. df = pd.DataFrame({'x':range(10)})
  3. df.plot(drawstyle = 'steps') # this works
  4. #df.plot(kind = 'area', drawstyle = 'steps') # this does not work
  5.  
  6. # For error bands around a series df
  7. ax.fill_between(df.index, df - offset, df + offset, step='pre', **kwargs)
  8.  
  9. # For filling the whole area below a function
  10. ax.fill_between(df.index, df, 0, step='pre', **kwargs)
  11.  
  12. out = df.plot(kind = 'line', drawstyle = 'steps') # stepped, not filled
  13. stepline = out.get_lines()[0]
  14. print(stepline.get_data())
  15.  
  16. df = pd.DataFrame({'x':range(10)})
  17. x = df.x.values
  18. xx = np.array([x,x])
  19. xx.flatten('F')
  20. doubled = xx.flatten('F') # NOTE! if x, y weren't the same, need a yy
  21. plt.fill_between(doubled[:-1], doubled[1:], label='area')
  22. ax = plt.gca()
  23. df.plot(drawstyle = 'steps', color='red', ax=ax)
  24.  
  25. import pandas as pd
  26. df = pd.DataFrame({'x':range(10)})
  27. df.plot(kind="bar",stacked=True,width = 1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement