Skip to content

sensible defaults and unittest #189

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

Merged
merged 16 commits into from
Apr 28, 2025
Merged

Conversation

cvanelteren
Copy link
Contributor

The community indicated (@ToryDeng) that colorbar label placing may need some TLC. We recently introduced placing colorbar labels along the outside of the colorbar. This may cause unnecessary post processing as currently the placingo f the labels is not stylized. This PR adds sensible label placement for colorbars. It adds a new keyword labelrotation which is set to default to "auto" or can be set to any arbitrary number; please note the the alignment is then null and void.

Furthermore, it adds the keyword outline which allows for turning on and off the outline frame of the colorbar.

Addresses #181

@TorryDeng do you want to include an rc param for the frame or is this sufficient?

@ToryDeng
Copy link

@TorryDeng do you want to include an rc param for the frame or is this sufficient?

Thanks for the prompt response! Adding an rc param would be helpful, especially when a figure contains multiple colorbars and users want to remove their frames.

@cvanelteren
Copy link
Contributor Author

@ToryDeng Done. New rc params is defined as colorbar.outline which defaults to True.

Copy link

codecov bot commented Apr 26, 2025

Codecov Report

Attention: Patch coverage is 79.72973% with 15 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
ultraplot/axes/base.py 83.87% 3 Missing and 2 partials ⚠️
ultraplot/internals/rcsetup.py 28.57% 4 Missing and 1 partial ⚠️
ultraplot/tests/test_colorbar.py 86.11% 3 Missing and 2 partials ⚠️

📢 Thoughts on this report? Let us know!

@cvanelteren cvanelteren requested review from beckermr and Copilot April 26, 2025 10:52
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refines the colorbar label placement by introducing a new keyword "labelrotation" with sensible default behaviors and a new keyword "outline" to toggle the colorbar's frame.

  • Adds tests to validate label rotation functionality and auto rotation settings.
  • Introduces new rc parameter "colorbar.outline" for managing colorbar frame visibility.
  • Updates the _add_colorbar function to incorporate labelrotation and outline parameters for enhanced customization.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
ultraplot/tests/test_colorbar.py Added tests for label rotation including auto and fixed rotation.
ultraplot/internals/rcsetup.py Added rc parameter for toggling colorbar outlines.
ultraplot/axes/base.py Updated _add_colorbar to support labelrotation and outline options.

@cvanelteren
Copy link
Contributor Author

Tests fail as expected. Here is the change:

2025-04-26T12:53:40,074016588+02:00

@cvanelteren
Copy link
Contributor Author

Doubting on making the label on the side default hor, but otherwise fine with the PR.

Copy link
Collaborator

@beckermr beckermr left a comment

Choose a reason for hiding this comment

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

One comment here.

@cvanelteren
Copy link
Contributor Author

Any preferences for the horizontal labels @ToryDeng not sure what to do here.

@ToryDeng
Copy link

Any preferences for the horizontal labels @ToryDeng not sure what to do here.

Yes horizontal labels may not be always good for horizontal colorbars with labels to the left or right. I think ​​vertical labels​​ could be set as ​​the default in this case. Just provide users with options to adjust if needed.

Copy link
Collaborator

@beckermr beckermr left a comment

Choose a reason for hiding this comment

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

A few more items.

@cvanelteren cvanelteren merged commit eb7fef5 into Ultraplot:main Apr 28, 2025
4 of 5 checks passed
@cvanelteren cvanelteren deleted the enhance-cbar branch April 28, 2025 06:59
cvanelteren added a commit to cvanelteren/ultraplot that referenced this pull request Apr 28, 2025
* Introduces new rc param. Th parameter `colorbar.outline` defaults to `True` and toggles the outline frame of the colorbar. 
* Allows figure colorbar label to be put on arbitrary side of the figure.


---------
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Matthew R. Becker <[email protected]>
cvanelteren added a commit to cvanelteren/ultraplot that referenced this pull request Apr 28, 2025
* Introduces new rc param. Th parameter `colorbar.outline` defaults to `True` and toggles the outline frame of the colorbar. 
* Allows figure colorbar label to be put on arbitrary side of the figure.


---------
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Matthew R. Becker <[email protected]>
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.

3 participants