I am using matplotlib
to plot a Time-series data on Jupyter Notebook. My Time-series data is a numpy.array
.
Here is my plot :
enter image description here
How can I highlight a specific sub-sequence on that plot ?
Here is my example :
asked Jan 13, 2018 at 9:14
1 Answer 1
Here is a small demo based on @Thomas Kühn comment:
x = np.linspace(-10, 10, 100)
plt.plot(x, np.sin(x))
plt.plot(x[60:80], np.sin(x[60:80]), lw=10, c='yellow', zorder=-1)
Result:
answered Jan 13, 2018 at 10:58
MaxU - stand with Ukraine MaxU - stand with UkraineMaxU - stand with Ukraine
212k37 gold badges402 silver badges435 bronze badges
-
thanks MaxU and Thomas. Now it's work !! I am just misunderstood the keyword
x
andy
.Tín Tr.– Tín Tr.2018年01月13日 11:03:33 +00:00Commented Jan 13, 2018 at 11:03 -
Perfect answer! You got my upvote already, just didn't have time to comment ;)Thomas Kühn– Thomas Kühn2018年01月14日 08:25:21 +00:00Commented Jan 14, 2018 at 8:25
-
@ThomasKühn, thank you! I didn’t know the trick with the "zorder", so I have learned something new from your comment! :)MaxU - stand with Ukraine– MaxU - stand with Ukraine2018年01月14日 08:56:26 +00:00Commented Jan 14, 2018 at 8:56
lang-py
plot(x,y,lw=10, c='yellow', zorder=-1)
and see if that is enough for your needs. The keywordzorder
determines in which order different elements are drawn -- smaller values are drawn before larger values.