Advertisement
SansPapyrus683

Matplotlib CW

Nov 22nd, 2022
935
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.71 KB | Source Code | 0 0
  1. import matplotlib.pyplot as plt
  2. import numpy as np
  3.  
  4. grades = [3, 8, 1, 4, 10, 9]
  5. week = list(range(1, len(grades) + 1))
  6.  
  7. max_grade = max(grades)
  8. min_grade = min(grades)
  9.  
  10. min_index = grades.index(min(grades))
  11. plt.plot(
  12.     week[:min_index + 1], grades[:min_index + 1], '-.k',
  13.     week[min_index:], grades[min_index:], ':k'
  14. )
  15. plt.plot(week[grades.index(max(grades))], max_grade, marker = "*")
  16. plt.plot(week[grades.index(min(grades))], min_grade, marker = "^")
  17.  
  18. threshold = 7
  19. for x in grades:
  20.     if threshold < x and x < max_grade:
  21.         plt.plot(week[grades.index(x)], x, marker='o')
  22.     elif min_grade < x and x < threshold:
  23.         plt.plot(week[grades.index(x)], x, marker='s')
  24.        
  25. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement