It looks like you have almost none. Define the colors first, then plot the scatter. So after print Tave create a list containing colors; To do this, I used the list:
y0colors = ['red' if value > Tave else 'yellow' for value in y0]
Then, when you create "Events", set color=y0colors , for example:
Events = ax.scatter(x0, z0, y0, color=y0colors)
Of course, with the requirement you are using, none of the dots will be blue. The y0 values ββare either greater than Tave ('red') or not ('yellow'). Perhaps this will be the way to do this after defining the scatter plot of "Events", but this way seems more direct.
source share