Guest User

Untitled

a guest
Mar 17th, 2018
339
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. +--- -----+------------+-------------+----------+------------+-----------+
  2. |avg_views| avg_orders | max_views |max_orders| min_views |min_orders |
  3. +---------+------------+-------------+----------+------------+-----------+
  4. | 23 | 123 | 135 | 500 | 3 | 1 |
  5. +---------+------------+-------------+----------+------------+-----------+
  6.  
  7. plt.figure(figsize=(13,7), dpi=300)
  8.  
  9. groups = [[23,135,3],
  10. [123,500,1]]
  11. group_labels = ["views", "orders"]
  12. num_items = len(group_labels)
  13. ind = np.arange(num_items)
  14. margin = 0.05
  15. width = (1.-2.*margin)/num_items
  16.  
  17. s = plt.subplot(1,1,1)
  18. for num, vals in enumerate(groups):
  19. print "plotting: ", vals
  20. # The position of the xdata must be calculated for each of the two data series
  21. xdata = ind+margin+(num*width)
  22. # Removing the "align=center" feature will left align graphs, which is what
  23. # this method of calculating positions assumes
  24. gene_rects = plt.bar(xdata, vals, width)
  25. s.set_xticks(ind+0.5)
  26. s.set_xticklabels(group_labels)
  27.  
  28. import pandas as pd
  29.  
  30. groups = [[23,135,3], [123,500,1]]
  31. group_labels = ['views', 'orders']
  32.  
  33. # Convert data to pandas DataFrame.
  34. df = pd.DataFrame(groups, index=group_labels).T
  35.  
  36. # Plot.
  37. pd.concat(
  38. [df.mean().rename('average'), df.min().rename('min'),
  39. df.max().rename('max')],
  40. axis=1).plot.bar()
Add Comment
Please, Sign In to add comment