0

enter image description hereI have a subplot with to time series in one graph. Using the code :

df1 = pd.read_csv('data1.csv')
df2 = pd.read_csv('data2.csv')

plt.plot(df2['Date'],df2[data2'])
plt.plot(df2['Date'],df1['data1'])

plt.show()

Now I want to shade the areas when data2 cross a certain value. Is there a way to do this?

Dennis
  • 195
  • 1
  • 2
  • 11
  • Can you draw a mock-up of what you mean by this? Maybe you're looking for [`fill_between`](https://matplotlib.org/3.1.1/gallery/recipes/fill_between_alpha.html) – Dan Jul 22 '19 at 10:54
  • No, i want to create vertical bars where the y-value is greater than "0.5" for example. – Dennis Jul 22 '19 at 11:00
  • draw a picture - it's impossible to know what you want otherwise – Dan Jul 22 '19 at 11:01
  • 1
    just add the image in my post. I want to shade the areas where the orange line is above 0.5 – Dennis Jul 22 '19 at 11:04
  • I don't know what you mean by "shade". You need to draw a mock-up of what you want. Shade it yourself by hand so we can see what you want. – Dan Jul 22 '19 at 12:04
  • try to do this.. the areas between the grey bars should be shaded – Dennis Jul 22 '19 at 12:17
  • Does this answer your question: https://stackoverflow.com/questions/23248435/fill-between-two-vertical-lines-in-matplotlib? – Dan Jul 22 '19 at 12:23
  • Yes, but this is just for two given x values, i want the same but for certain y-values – Dennis Jul 22 '19 at 12:42
  • 1
    You can get the dates with something along the lines of `df2.loc[df2['data2'] > threshold ,'Date']` and then use those dates as the x values in your comment above... – Dan Jul 22 '19 at 12:48
  • I don't get it.. I can't transmitted the answer to my code and the use of data frames – Dennis Jul 22 '19 at 13:06
  • Make an [MCVE](https://meta.stackoverflow.com/questions/366988/what-does-mcve-mean) with simple sample data – Dan Jul 22 '19 at 13:12

0 Answers0