0

i have a df=pd.DataFrame(columns=['time','value']) df.time is of time format, but it does not contain all the time value in the day, e.g. it may skip 2 or 3 hours in the day. when I plot, those non-exist values get disrupted and result in a horizontal line. [non-exist-time-x-asix] https://ibb.co/mTeMG7

how shall I plot without those non-exist time value? ~~~~~~~~~~~~~~~~~~~~~~~

a sample of the DataFrame, you can see the time column has a gap between 11:30 and 13:01, and when it plot, the gap are plotted as a straight line.

time    value
2018-05-02 11:27:50 0.259985004211
2018-05-02 11:28:21 0.259545644369
2018-05-02 11:28:51 0.25979798095
2018-05-02 11:29:21 0.260563452643
2018-05-02 11:29:51 0.259673487744
2018-05-02 13:01:22 0.260134861813
2018-05-02 13:01:52 0.259365665332
2018-05-02 13:02:22 0.258942165755
2018-05-02 13:02:52 0.258489853316
2018-05-02 13:03:22 0.259211996329
mojop
  • 9
  • 4
  • could you share a sample set to better understand your question? in the plot one might think you have constant values (~ 6170?) for the missing hours, is it so? – filippo May 01 '18 at 13:06
  • See [this example](https://matplotlib.org/examples/pylab_examples/broken_axis.html) or [this question](https://stackoverflow.com/questions/5656798/python-matplotlib-is-there-a-way-to-make-a-discontinuous-axis). – ImportanceOfBeingErnest May 01 '18 at 21:55
  • Hi fllippo, just put a snapshot of the df. – mojop May 02 '18 at 05:17
  • anyone can help with reducing the gap in the time axis? – mojop May 04 '18 at 08:25

0 Answers0