From 3c671403e4c2075da276e4835c350a45b67e52be Mon Sep 17 00:00:00 2001 From: "Ankur Sinha (Ankur Sinha Gmail)" Date: Tue, 7 Nov 2023 14:55:18 +0000 Subject: [PATCH] feat(matrix-handler): tweak tick size relative to defaults This allows users to modify the tick size by changing the defaults, which is very useful: https://matplotlib.org/stable/users/explain/customizing.html --- neuromllite/MatrixHandler.py | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/neuromllite/MatrixHandler.py b/neuromllite/MatrixHandler.py index b302f38..68b9d2b 100644 --- a/neuromllite/MatrixHandler.py +++ b/neuromllite/MatrixHandler.py @@ -308,14 +308,33 @@ def finalise_document(self): ax.set_yticklabels(entries) ax.set_xticklabels(entries) ax.set_ylabel("presynaptic") - tick_size = ( - 10 + + # change in relation to default so that users can override + default_tick_size_x = matplotlib.rcParams["xtick.labelsize"] + tick_size_x = ( + default_tick_size_x if weight_array.shape[0] < 20 - else (8 if weight_array.shape[0] < 40 else 6) + else ( + (default_tick_size_x - 2) + if weight_array.shape[0] < 40 + else (default_tick_size_x - 4) + ) ) - ax.tick_params(axis="y", labelsize=tick_size) + ax.tick_params(axis="x", labelsize=tick_size_x) + + default_tick_size_y = matplotlib.rcParams["ytick.labelsize"] + tick_size_y = ( + default_tick_size_y + if weight_array.shape[0] < 20 + else ( + (default_tick_size_y - 2) + if weight_array.shape[0] < 40 + else (default_tick_size_y - 4) + ) + ) + ax.tick_params(axis="y", labelsize=tick_size_y) + ax.set_xlabel("postsynaptic") - ax.tick_params(axis="x", labelsize=tick_size) fig.autofmt_xdate() for i in range(len(entries)):