I plot a lot of data on daily cycles, where there is no data collected at night. Let’s mock up some sample data with the following simple code:

Error pygmentizing...

Then I get a plot like this:

This plot doesn’t show the nightly breaks in data well. Connecting the last data point collected from a day to the first data point collected the next day emphasizes the trend between these points, which may not be appropriate.

I have been using a fairly simple routine to insert NaNs into the data to break the plot into disconnected sections. For example, modify the above data for plotting with:

Error pygmentizing...

The new plot shows the gaps between the “days” in the data: