Python: Matplotlib avoids creating spaces

I am currently creating a plot below: plot

using this code:

ax = plt.subplots()
ax.plot(intra.to_pydatetime(), data)
plt.title('Intraday Net Spillover')
fig.autofmt_xdate()

where intra.to_pydatetime()is: <bound method DatetimeIndex.to_pydatetime of <class 'pandas.tseries.index.DatetimeIndex'> [2011-01-03 09:35:00, ..., 2011-01-07 16:00:00] Length: 390, Freq: None, Timezone: None>

So, dates start with 2011-01-03 09:35:00, increase by 5 minutes before 16:00:00, and then move on the next day, 2011-01-04 09:35:00to 2011-01-04 16:00:00, etc.

How can I avoid scheduling between 16:00:00 and 9:30:00 the next day? I do not want to see these lines.

UPDATE:

I will try this one to see if it works.

+1
source share
1 answer

Just set two values ​​that define the string you don't want to see as NaN (Not a Number). Matplotlib will automatically hide the line between the two values.

: http://matplotlib.org/examples/pylab_examples/nan_test.html

+3

Source: https://habr.com/ru/post/1626532/


All Articles