From 2101f39f3da85da9af3f82fae31bd2897a63aaa4 Mon Sep 17 00:00:00 2001 From: Chiara Monforte Date: Thu, 28 Nov 2024 12:28:32 +0100 Subject: [PATCH 1/2] [FIX BUG] Axis labels are wrong when ytick are not fixed For the IOOS qc plots in case we have no good data or we do not have a tick for every point, then the new labels are assigned wrong. I am not forcing ticks to always be from 0 to 10 so we assign the new labels correctly --- glidertest/plots.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/glidertest/plots.py b/glidertest/plots.py index 1960cd3..4dab946 100644 --- a/glidertest/plots.py +++ b/glidertest/plots.py @@ -1181,20 +1181,22 @@ def plot_ioosqc(data, suspect_threshold=[25], fail_threshold=[50], title='', ax= force_plot = False ax.scatter(np.arange(len(data)), data, s=4) + ax.set_yticks([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) a = ax.get_yticks().tolist() - a[1:] = ['GOOD', 'UNKNOWN', 'SUSPECT', 'FAIL', '', '', '', '', 'MISSING'] + a[:] = ['', 'GOOD', 'UNKNOWN', 'SUSPECT', 'FAIL', '', '', '', '', 'MISSING', ''] ax.set_yticklabels(a) ax2 = ax.twinx() ax2.scatter(np.arange(len(data)), data, s=4) - + ax2.set_yticks([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) a_2 = ax2.get_yticks().tolist() - a_2[1:] = ['', '', '', '', '', '', '', '', ''] + a_2[:] = ['', '', '', '', '', '', '', '', '', '', ''] if len(suspect_threshold) > 1: a_2[1] = f'x>{suspect_threshold[0]} or \nx<{suspect_threshold[1]}' else: a_2[1] = f'x<{suspect_threshold[0]}' if len(fail_threshold) > 1: - a_2[3] = f'{suspect_threshold[1]}{fail_threshold[1]}' else: a_2[3] = f'x>{suspect_threshold[0]} and \nx<{fail_threshold[0]}' @@ -1202,9 +1204,10 @@ def plot_ioosqc(data, suspect_threshold=[25], fail_threshold=[50], title='', ax= a_2[9] = 'Nan' ax2.set_yticklabels(a_2, fontsize=12) + ax.set_xlabel('Data Index') ax.grid() ax.set_title(title) if force_plot: plt.show() - return fig, ax \ No newline at end of file + return fig, ax From 5b26abf4592090e08214def8d56dfae27058f070 Mon Sep 17 00:00:00 2001 From: Chiara Monforte Date: Thu, 28 Nov 2024 12:32:11 +0100 Subject: [PATCH 2/2] typo --- glidertest/plots.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/glidertest/plots.py b/glidertest/plots.py index 4dab946..5ba18f2 100644 --- a/glidertest/plots.py +++ b/glidertest/plots.py @@ -1195,8 +1195,7 @@ def plot_ioosqc(data, suspect_threshold=[25], fail_threshold=[50], title='', ax= else: a_2[1] = f'x<{suspect_threshold[0]}' if len(fail_threshold) > 1: - a_2[ - 3] = f'{suspect_threshold[1]}{fail_threshold[1]}' else: a_2[3] = f'x>{suspect_threshold[0]} and \nx<{fail_threshold[0]}'