Advertisement
OreganoHauch

histogram

Dec 8th, 2020
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. def histogram(input1=1, input2=2,input2_random=False):
  2. fig, ax = plt.subplots(figsize=(10,5))
  3. groups1 = np.array(load_cache_kmeans(kmeans_input = input1)["2"]["cluster_numbers"])
  4. if input2_random:
  5. groups2 = np.random.randint(2,size=(1000,1000))+1
  6. else:
  7. groups2 = np.array(load_cache_kmeans(kmeans_input = input2)["2"]["cluster_numbers"])
  8. OneOne = 0
  9. OneTwo = 0
  10. TwoOne = 0
  11. TwoTwo = 0
  12. for z in np.arange(0,1000,1):
  13. for y in np.arange(0,1000,1):
  14. if groups1[y][z] == 1 and groups2[y][z] == 1:
  15. OneOne += 1
  16. if groups1[y][z] == 1 and groups2[y][z] == 2:
  17. OneTwo += 1
  18. if groups1[y][z] == 2 and groups2[y][z] == 1:
  19. TwoOne += 1
  20. if groups1[y][z] == 2 and groups2[y][z] == 2:
  21. TwoTwo += 1
  22. labels = ["1 & 1", "1 & 2", "2 & 1", "2 & 2"]
  23. visitors = (OneOne,OneTwo,TwoOne,TwoTwo)
  24. index = np.arange(4)
  25. bar_width = 0.9
  26. plt.bar(index, visitors, bar_width, color="green")
  27. plt.xticks(index, labels) # labels get centered
  28. plt.show()
  29. histogram()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement