Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

how can I fill all the space between the two point on x-axis

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>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()]?

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading