Skip to content

Commit

Permalink
💄 Update colors
Browse files Browse the repository at this point in the history
NoaSecond committed May 31, 2024
1 parent 966a958 commit 109faf1
Showing 2 changed files with 23 additions and 7 deletions.
4 changes: 2 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
@@ -181,7 +181,7 @@ def refresh_ports():

# realTimePlot
# Vacuum pump
plot1 = realTimePlot.RealTimePlot()
plot1 = realTimePlot.RealTimePlot("Plot 1")
plot1.start_animation()
figure = plot1.figure
listWidget_vacuum = MainWindow.findChild(QtWidgets.QListWidget, "listWidget_vacuum")
@@ -190,7 +190,7 @@ def refresh_ports():
listWidget_vacuum.addItem(item)
listWidget_vacuum.setItemWidget(item, figure.canvas)
# Magnet
plot2 = realTimePlot.RealTimePlot()
plot2 = realTimePlot.RealTimePlot("Plot 2")
plot2.start_animation()
figure = plot2.figure
listWidget_magnet = MainWindow.findChild(QtWidgets.QListWidget, "listWidget_magnet")
26 changes: 21 additions & 5 deletions scripts/realTimePlot.py
Original file line number Diff line number Diff line change
@@ -4,12 +4,28 @@
from random import randrange
from PyQt5 import QtWidgets


class RealTimePlot:
def __init__(self):
def __init__(self, title):
self.x_data, self.y_data = [], []
self.figure, self.ax = plt.subplots()
self.line, = self.ax.plot_date(self.x_data, self.y_data, '-')
self.animation = None # Keep a reference to the animation object
self.ax.set_title(title)
self.line, = self.ax.plot_date(
self.x_data, self.y_data, '-', color='white') # Set line color to white
self.animation = None # Ref animation object
# Colors
self.figure.patch.set_facecolor('#424242')
self.ax.set_facecolor('#424242')
self.ax.spines['bottom'].set_color('white')
self.ax.spines['top'].set_color('white')
self.ax.spines['left'].set_color('white')
self.ax.spines['right'].set_color('white')
self.ax.tick_params(axis='x', colors='white')
self.ax.tick_params(axis='y', colors='white')
self.ax.yaxis.label.set_color('white')
self.ax.xaxis.label.set_color('white')
self.ax.title.set_color('white')


def update(self, frame):
if not self.x_data:
@@ -23,8 +39,8 @@ def update(self, frame):
return self.line,

def start_animation(self, interval=200):
self.animation = FuncAnimation(self.figure, self.update, interval=interval, cache_frame_data=False)
# plt.show() # Ensure the plot window is shown
self.animation = FuncAnimation(
self.figure, self.update, interval=interval, cache_frame_data=False)

def add_plot(self, MainWindow, widget_name):
widget = MainWindow.findChild(QtWidgets.QWidget, widget_name)

0 comments on commit 109faf1

Please sign in to comment.