I was trying to plot the temperature of my Raspberry Pi and display that plot on a webpage. This works reasonably well. However, I was trying to color different regions of the plot according to the perceived risk (I'm not sure if they actually pose a risk to my Pi, but I wouldn't feel comfortable running it at e.g. 90°C).
I'm using this code to create the plot:
fig = plt.figure()
# color regions
plt.fill([0, 0, len(temps)-1, len(temps)-1], [80, 100, 100, 80], 'r', alpha=0.2, linestyle=None)
plt.fill([0, 0, len(temps)-1, len(temps)-1], [60, 80, 80, 60], 'y', alpha=0.2, linestyle=None)
plt.fill([0, 0, len(temps)-1, len(temps)-1], [0, 60, 60, 0], 'g', alpha=0.2, linestyle=None)
# modify axis
plt.axis([0, len(temps)-1, 0, 100])
plt.xticks([])
# plot and safe
plt.plot(temps, color='k')
plt.savefig(buf, format='png')
plt.close(fig)
This creates the following plot:
I don't like the "hard edges" of the regions, but I can't seem to find a way to let them "flow" into each other. Does anyone know how to solve this or can point me in the right direction?