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

✨ Add add_subplot_labels function #181

Merged
merged 6 commits into from
Jul 3, 2023
Merged

Conversation

s-weigand
Copy link
Member

@s-weigand s-weigand commented Jul 1, 2023

This adds add_subplot_labels as a convenience function to add subplot labels.

Instead of duplicating code for each axis possibly creating inconsistency.

axes[0].annotate("A", xy=(0.01, 0.89), xycoords="axes fraction", fontsize=16)
axes[1].annotate("B", xy=(0.01, 0.89), xycoords="axes fraction", fontsize=16)
axes[2].annotate("C", xy=(0.01, 0.89), xycoords="axes fraction", fontsize=16)

This function allows adding labels consistently for all axes

add_subplot_labels(axes, label_position=(0.01, 0.89), label_format_function="upper_case_letter")

Change summary

Checklist

  • ✔️ Passing the tests (mandatory for all PR's)
  • 🧪 Adds new tests for the feature (mandatory for ✨ feature and 🩹 bug fix PR's)

@s-weigand s-weigand requested a review from a team as a code owner July 1, 2023 16:27
@github-actions
Copy link
Contributor

github-actions bot commented Jul 1, 2023

Binder 👈 Launch a binder notebook on branch s-weigand/pyglotaran-extras/anotate

"polar",
]

SubPlotLabelCoord: TypeAlias = (

Check notice

Code scanning / CodeQL

Unused global variable

The global variable 'SubPlotLabelCoord' is not used.
pyglotaran_extras/plotting/utils.py Fixed Show fixed Hide fixed
@codecov
Copy link

codecov bot commented Jul 1, 2023

Codecov Report

Patch coverage: 94.11% and project coverage change: +1.59 🎉

Comparison is base (289c3c3) 43.30% compared to head (510fc30) 44.90%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #181      +/-   ##
==========================================
+ Coverage   43.30%   44.90%   +1.59%     
==========================================
  Files          27       27              
  Lines         979     1011      +32     
  Branches      142      149       +7     
==========================================
+ Hits          424      454      +30     
- Misses        548      549       +1     
- Partials        7        8       +1     
Impacted Files Coverage Δ
pyglotaran_extras/plotting/utils.py 37.80% <92.59%> (+9.74%) ⬆️
pyglotaran_extras/__init__.py 100.00% <100.00%> (ø)
pyglotaran_extras/types.py 100.00% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

axes = axes.T
for i, ax in enumerate(axes.flatten(), start=1):
ax.annotate(
label_format_template.format(format_function(i, axes.size)),

Check failure

Code scanning / CodeQL

Non-callable called

Call to a [non-callable](1) of [builtin-class str](2).
Copy link
Member

@jsnel jsnel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

I do note that 'advanced' (or complex) functionality like this could do with some additional documentation in the form of examples (rather than just the API docstrings), something like some snippets in the readme, or example notebooks. Suggest we made an issue of this for a future PR. Because of the tight coupling between pyglotaran and the -extras it can be done in either repository, but it may make more sense to be in -extras as a self-contained example.

@jsnel jsnel merged commit a2f14b4 into glotaran:main Jul 3, 2023
@s-weigand s-weigand deleted the anotate branch July 9, 2023 21:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants