'Matplotlib plot lines are choppy

I have some plots generated by matplotlib, which I have been generating using the same code (for different data) for several years. The plots always come out looking normal. This time, I re-ran the same code using different data, and the plots showed up like this:

(Note that the missing border at the top is the result of my erasing the legend. The problem is the choppy, broken up blue and orange data lines.) Many of the plots generated are broken up like this, but not all are. All were normal the previous times that I ran this code.

I have no idea what's going on to make the lines all broken up like this. I tried re-starting my computer and it didn't help. I can't seem to find anything online about this issue. Does anyone have any idea what's going on here?

Here's the code that generated it (excerpted)

`

 import matplotlib
 from numpy import NaN
 matplotlib.use('Agg')
 from matplotlib import pyplot as plt
 from PyPDF2 import PdfFileMerger, PdfFileReader

 for chan in channels:
     dProd.plot(x='Date',y=[a_chan,b_chan],secondary_y=b_chan)
     plt.title(chan).get_figure().savefig(folder+'\\'+prod+'\\plots\\'+chan+'.pdf')
     plt.close('all')     
             

`



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source