Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX BUG] Axis labels are wrong when ytick are not fixed #142

Merged
merged 2 commits into from
Nov 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions glidertest/plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -1181,14 +1181,15 @@ 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:
Expand All @@ -1202,9 +1203,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
return fig, ax