I want to fill the space between two point on x-axis kindly check the image here. The code I tried is as follows
import matplotlib.pyplot as plt
import pandas as pd
data = pd.read_csv('data.csv')
plt.figure(figsize=(15, 7))
plt.plot(data.x, data.y)
plt.fill_betweenx(y=data.y, x1 = 600, x2 = 1200, alpha = 0.5, color = 'green')
plt.show()
and I cannot figure out what is the problem here, please help
>Solution :
Here is a working example:
import matplotlib.pyplot as plt
import pandas as pd
plt.figure(figsize=(15, 7))
plt.plot([0, 1], [2, 3])
plt.fill_betweenx(y=[2.5, 2.9], x1 = .2, x2 = .4, alpha = 0.5, color = 'green')
plt.show()
Since your example is not reproducible I can’t help more.
Maybe replace y=data.y by y=[data.y.min(), y=data.y.max()]?