0

enter image description hereSo I want to find the way to change the plot every single time whenever it reaches a new month. So for example, when it reaches January the plot will be blue, when it reaches February the plot will be red etc till December.

    import matplotlib.pyplot as plt

    # Monthly average precipitation
    boulder_monthly_precip = [0.70, 0.75, 1.85, 2.93, 3.05, 2.02, 
                              1.93, 1.62, 1.84, 1.31, 1.39, 0.84]
     
    months = ["Jan", "Feb", "Mar", "Apr", "May", "June", "July", 
              "Aug", "Sept", "Oct", "Nov", "Dec"]
    
    for i in range(len(months)):
   ...:     if months[i] == "Jan":
   ...:         colour = "red"
   ...:         plt.plot(boulder_monthly_precip, months, color=colour)
   ...:     elif months[i] == "Feb":
   ...:         colour = "green"
   ...:         plt.plot(boulder_monthly_precip, months, color=colour)
   ...:     elif months[i] == 'Mar':
   ...:         colour = "orange"
   ...:         plt.plot(boulder_monthly_precip, months, color=colour)
   ...:     elif months[i] == "July":
   ...:         colour = "yellow"
   ...:         plt.plot(boulder_monthly_precip, months, color=colour)

And the result is:enter image description here

0 Answers0