From 530110b84a74eaa97268566b760b041839a1515f Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Tue, 16 Nov 2021 22:09:34 +0100 Subject: add optional dark mode --- bin/korad-logger | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/bin/korad-logger b/bin/korad-logger index e9d97f5..71e2965 100755 --- a/bin/korad-logger +++ b/bin/korad-logger @@ -52,6 +52,8 @@ import time terminate_measurement = False +matplotlib_theme = "fast" + def running_mean(x: np.ndarray, N: int) -> np.ndarray: """ @@ -308,7 +310,7 @@ def measure_data( if live_view: import matplotlib.pyplot as plt - plt.style.use("dark_background") + plt.style.use(matplotlib_theme) timestamps = list() voltages = list() @@ -427,6 +429,8 @@ def measure_data( def plot_data(data, mode): import matplotlib.pyplot as plt + plt.style.use(matplotlib_theme) + if mode == "U": (datahandle,) = plt.plot(data[:, 0], data[:, 1], "b-", label="U", markersize=1) (meanhandle,) = plt.plot( @@ -650,6 +654,9 @@ def main(): choices=["U", "I", "P", "UI", "UP", "IU", "IP"], help="Plot voltage / current / power over time or voltage vs current / current vs voltage", ) + parser.add_argument( + "--dark-mode", action="store_true", help="Show plots on a dark background" + ) parser.add_argument( "duration", type=int, nargs="?", help="Measurement duration in seconds" ) @@ -660,6 +667,10 @@ def main(): print("Either --load or duration must be specified", file=sys.stderr) sys.exit(1) + if args.dark_mode: + global matplotlib_theme + matplotlib_theme = "dark_background" + current_range = parse_range(args.current_range) voltage_range = parse_range(args.voltage_range) -- cgit v1.2.3