diff --git a/serial_plotter.py b/serial_plotter.py index cfe68f0..8681c53 100644 --- a/serial_plotter.py +++ b/serial_plotter.py @@ -20,6 +20,7 @@ class SerialPlotter: self.settings = json.load(open('settings.json', 'r')) self.sensors = len(self.settings['sensor_ports']) self.windowsize = self.settings['winSize'] + self.fontSize = self.settings['fontSize'] self.delay = self.settings["delay"] / 1000 self.colors = ['blue', 'orange', 'green', 'yellow'] @@ -79,19 +80,19 @@ class SerialPlotter: label=f'sensor {i + 1}, latest: {np.format_float_scientific(self.sensorsData[i][-1], precision = 2)} $\Omega$') # Make the font size of values placed on x-axis and y-aixs equal to 16 (large enough) - plt.xticks(fontsize = 16) - plt.yticks(fontsize = 16) + plt.xticks(fontsize = max(self.fontSize, 10)) + plt.yticks(fontsize = max(self.fontSize, 10)) # make the label of two axes large enough - self.axs.set_xlabel('Time (seconds)', fontsize = 15) - self.axs.set_ylabel(u'Resistance ($\Omega$)', fontsize = 15) + self.axs.set_xlabel('Time (seconds)', fontsize = max(self.fontSize, 10)) + self.axs.set_ylabel(u'Resistance ($\Omega$)', fontsize = max(self.fontSize, 10)) i += 1 self.timeElapsed += 1 # increment time # Acknowledgement: https://stackoverflow.com/a/13589144 handles, labels = self.axs.get_legend_handles_labels() by_label = dict(zip(labels, handles)) - self.axs.legend(by_label.values(), by_label.keys(), loc='best', fontsize = 15) # Make the legend on graph large enough + self.axs.legend(by_label.values(), by_label.keys(), loc='best', fontsize = max(self.fontSize, 10)) # Make the legend on graph large enough except: traceback.print_exc() diff --git a/test.py b/test.py index d764216..63bbc7b 100644 --- a/test.py +++ b/test.py @@ -33,6 +33,7 @@ def main(): port = frame.dev_list.GetValue() # typical window size: 50 window_size = int(frame.m_textCtrl26.GetValue()) + font_size = int(frame.fontSize.GetValue()) #################### END USER INPUTS ######################## @@ -46,10 +47,10 @@ def main(): if not (len(resistors) == 5): raise ValueError(f"expecting 5 resistor values, but got {len(resistors)}!!!") - gen_settings(resistors, input_voltage, port, filename, window_size, delay) + gen_settings(resistors, input_voltage, port, filename, window_size, font_size, delay) -def gen_settings(resistors, input_voltage, port, filename, window_size, delay): +def gen_settings(resistors, input_voltage, port, filename, window_size, font_size, delay): """ export all inputs from main() to a .json file :param resistors: list of reference resistances of the sensors @@ -68,6 +69,7 @@ def gen_settings(resistors, input_voltage, port, filename, window_size, delay): settings["port"] = port # settings["resolution"] = bits settings["winSize"] = window_size + settings["fontSize"] = font_size settings["file_name"] = filename settings["delay"] = delay open(name, 'w').write(json.dumps(settings, indent=4))