Switch the Plot tab to a bright theme with a refined grid and ticks
Drop dark_background in favor of a plain white figure, matching demo_sud's blue/red ist/soll color convention. Add faint major/minor gridlines, drop the top/right spines, and use label_outer() so only the bottom subplot repeats x tick labels across the shared time axis.
This commit is contained in:
+24
-12
@@ -6,10 +6,9 @@ import sys
|
|||||||
import time
|
import time
|
||||||
import matplotlib
|
import matplotlib
|
||||||
matplotlib.use("Qt5Agg")
|
matplotlib.use("Qt5Agg")
|
||||||
import matplotlib.style
|
|
||||||
matplotlib.style.use("dark_background")
|
|
||||||
from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg
|
from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg
|
||||||
from matplotlib.figure import Figure
|
from matplotlib.figure import Figure
|
||||||
|
from matplotlib.ticker import AutoMinorLocator
|
||||||
from ws.client.ws_client import WsClient
|
from ws.client.ws_client import WsClient
|
||||||
from ws.message import MessageDispatcherSync
|
from ws.message import MessageDispatcherSync
|
||||||
from queue import Queue
|
from queue import Queue
|
||||||
@@ -22,29 +21,42 @@ class RealtimePlot(FigureCanvasQTAgg):
|
|||||||
instead of an offline simulation run."""
|
instead of an offline simulation run."""
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
figure = Figure()
|
figure = Figure(facecolor='white')
|
||||||
FigureCanvasQTAgg.__init__(self, figure)
|
FigureCanvasQTAgg.__init__(self, figure)
|
||||||
|
|
||||||
self.ax_temp, self.ax_rate, self.ax_power = figure.subplots(3, 1, sharex=True)
|
self.ax_temp, self.ax_rate, self.ax_power = figure.subplots(3, 1, sharex=True)
|
||||||
|
|
||||||
self.line_temp_ist, = self.ax_temp.plot([], [], '-c', linewidth=1, label="theta_ist")
|
self.line_temp_ist, = self.ax_temp.plot([], [], '-b', linewidth=1, label="theta_ist")
|
||||||
self.line_temp_soll, = self.ax_temp.plot([], [], '-m', linewidth=1, label="theta_soll")
|
self.line_temp_soll, = self.ax_temp.plot([], [], '-r', linewidth=1, label="theta_soll")
|
||||||
self.ax_temp.set_ylabel("Temp [°C]")
|
self.ax_temp.set_ylabel("Temp [°C]")
|
||||||
self.ax_temp.legend(loc='upper left', fontsize='small')
|
self.ax_temp.legend(loc='upper left', fontsize='small')
|
||||||
self.ax_temp.grid(True)
|
|
||||||
|
|
||||||
self.line_rate_ist, = self.ax_rate.plot([], [], '-c', linewidth=1, label="heatrate_ist")
|
self.line_rate_ist, = self.ax_rate.plot([], [], '-b', linewidth=1, label="heatrate_ist")
|
||||||
self.line_rate_soll, = self.ax_rate.plot([], [], '-m', linewidth=1, label="heatrate_soll")
|
self.line_rate_soll, = self.ax_rate.plot([], [], '-r', linewidth=1, label="heatrate_soll")
|
||||||
self.ax_rate.set_ylabel("Rate [K/min]")
|
self.ax_rate.set_ylabel("Rate [K/min]")
|
||||||
self.ax_rate.legend(loc='upper left', fontsize='small')
|
self.ax_rate.legend(loc='upper left', fontsize='small')
|
||||||
self.ax_rate.grid(True)
|
|
||||||
|
|
||||||
self.line_power_set, = self.ax_power.plot([], [], '-m', linewidth=1, label="power_set")
|
self.line_power_set, = self.ax_power.plot([], [], '-r', linewidth=1, label="power_set")
|
||||||
self.line_power_eff, = self.ax_power.plot([], [], '-c', linewidth=1, label="power_eff")
|
self.line_power_eff, = self.ax_power.plot([], [], '-b', linewidth=1, label="power_eff")
|
||||||
self.ax_power.set_ylabel("Power [W]")
|
self.ax_power.set_ylabel("Power [W]")
|
||||||
self.ax_power.set_xlabel("t [s]")
|
self.ax_power.set_xlabel("t [s]")
|
||||||
self.ax_power.legend(loc='upper left', fontsize='small')
|
self.ax_power.legend(loc='upper left', fontsize='small')
|
||||||
self.ax_power.grid(True)
|
|
||||||
|
for ax in (self.ax_temp, self.ax_rate, self.ax_power):
|
||||||
|
ax.set_facecolor('white')
|
||||||
|
ax.spines['top'].set_visible(False)
|
||||||
|
ax.spines['right'].set_visible(False)
|
||||||
|
ax.xaxis.set_minor_locator(AutoMinorLocator())
|
||||||
|
ax.yaxis.set_minor_locator(AutoMinorLocator())
|
||||||
|
ax.tick_params(which='major', direction='out', labelsize='small')
|
||||||
|
ax.tick_params(which='minor', direction='out', length=2)
|
||||||
|
ax.grid(which='major', linestyle='-', linewidth=0.5, alpha=0.3)
|
||||||
|
ax.grid(which='minor', linestyle=':', linewidth=0.5, alpha=0.15)
|
||||||
|
|
||||||
|
# Only the bottom subplot needs x tick labels - sharex keeps the
|
||||||
|
# others in sync without repeating them.
|
||||||
|
self.ax_temp.label_outer()
|
||||||
|
self.ax_rate.label_outer()
|
||||||
|
|
||||||
figure.tight_layout()
|
figure.tight_layout()
|
||||||
self.reset()
|
self.reset()
|
||||||
|
|||||||
Reference in New Issue
Block a user