Guest User

Untitled

a guest
Nov 12th, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. import random
  2. import pandas as pd
  3. import numpy as np
  4. import matplotlib.pyplot as plt
  5.  
  6. s = "Crime Type Summer|Crime Type Winter".split("|")
  7. j = {x: [random.choice(["ASB", "Violence", "Theft", "Public Order", "Drugs"]) for j in range(300)] for x in s}
  8. df = pd.DataFrame(j)
  9.  
  10. index = np.arange(5)
  11. bar_width = 0.35
  12.  
  13. fig, ax = plt.subplots()
  14. summer = ax.bar(index, df["Crime Type Summer"].value_counts(), bar_width,
  15. label="Summer")
  16.  
  17. winter = ax.bar(index, df["Crime Type Winter"].value_counts(),
  18. bar_width, label="Winter", bottom=df["Crime Type Summer"].value_counts())
  19.  
  20. ax.set_xlabel('Category')
  21. ax.set_ylabel('Incidence')
  22. ax.set_title('Crime incidence by season, type')
  23. ax.set_xticks(index)
  24. ax.set_xticklabels(["ASB", "Violence", "Theft", "Public Order", "Drugs"])
  25. ax.legend()
  26.  
  27. plt.show()
Add Comment
Please, Sign In to add comment