I have started using plotnine and would like to create a chart with a red area above 40 and a blue area below -40.
chart with red and blue rectangles
I was able to approximate it with the following code, but it seems hacky. What is the "correct" way to do this?
import pandas as pd
from plotnine import *
vals = np.random.randint(-50, 50, size=20)
df = pd.DataFrame({"val":vals})
ggplot(df, aes(x=df.index, y = 'val')) \
+ geom_line() \
+ geom_hline(yintercept=40, size=20, colour='red', alpha=0.5) \
+ geom_hline(yintercept=-40, size=20, colour='blue', alpha=0.5)