Search code examples
pythonmatplotlibgraphing

Why do these Python Matplotlib graphs display differently across different computers?


I wrote a program that gathers data and plots it (y) over time (x). I use Python 3.7.7, with matplotlib 3.2.2, on Windows 10 Pro. I have compiled the program using pyinstaller, into an .exe and put it on additional computers to run. The program has worked properly on all computers, except an HP i5, running Windows 7 & 10. I've attached a picture of both graphs to help explain my problem... Good and Bad Grpah

The bad graph seems to display the data sporadically with long horizontal lines between data points. I have created a debug version that displays the data of the lists used for the x and y axis and the lists are full with 80-110 values, so I know the data is being collected. It's just not displaying on the graph properly.

I have tried uninstalling things and installing things, I have tweaked the priority in Task Manager, and I've tried running in SAFE mode to disable any extensions that may be interrupting in the background.

Does anyone have ANY ideas or help? Thank you in advance!

Code snippet:

def Laser_WaferScan(self, lst, display1, time_lst):
""" Laser - WAFER SCAN PLOT """
waferScan = lst
rpms = display1                 # Displays the RPMs in plt.title
waferScan_fullScan_time_lst = time_lst


#### TESTING - Moved from main() 6.1.20
if gv.bandpass_yes == True:
    plt.subplot(3, 1, 1) 
else:
    plt.subplot(2, 1, 1)
##########################################

# Dynamically setup graph axes using Plotting class
waferScan_min_ylim, waferScan_max_ylim = self.Ylim(waferScan)
plt.ylim(waferScan_min_ylim, waferScan_max_ylim)
# Compare the last value added to the waferScan_fullScan_time_lst, and if it is greater than the current X-axis limit, make it the new X-axis limit
if waferScan_fullScan_time_lst[-1] > gv.waferScan_max_xlim: 
    gv.waferScan_max_xlim = waferScan_fullScan_time_lst[-1]
plt.xlim(0, gv.waferScan_max_xlim)

if gv.scan_name != None:            # These conditional statements check to see which title should be used
    if gv.lowpass_yes == True:
        plt.title(f"{gv.scan_name}\nLowpass Filter Settings:     N: {gv.lowpass_N}     Wn: {gv.lowpass_Wn}\nRPMs = {rpms}     Time to Scan = {round(gv.adjusted_time_to_scan,4)} sec", fontsize=12)
    else:
        plt.title(f"{gv.scan_name}\nRPMs = {rpms}     Time to Scan = {round(gv.adjusted_time_to_scan,4)} sec", fontsize=12)
else: 
    if gv.lowpass_yes == True:
        plt.title(f"Lowpass Filter Settings:     N: {gv.lowpass_N}     Wn: {gv.lowpass_Wn}\nRPMs = {rpms}     Time to Scan = {round(gv.adjusted_time_to_scan,4)} sec", fontsize=12)
    else:
        plt.title(f"RPMs = {rpms}     Time to Scan = {round(gv.adjusted_time_to_scan,4)} sec", fontsize=12)
plt.ylabel("Full Wafer Scan (volts)")
plt.xlabel('Full Wafer Scan Time (milliseconds)', fontsize=10)
plt.plot(waferScan_fullScan_time_lst, waferScan, label="Laser Readings", color='k')

Solution

  • It turns out that the computer in question that would display the bad plot had McAfee Antivirus installed on it and this caused the issue with scanning the .exe and delaying the output of data to matplotlib. Once we added the .exe and necessary programs into the "exclusion" list, we were able to get the graph to display correctly.

    In some roundabout way, I would consider McAfee a virus in and of itself.