-
Notifications
You must be signed in to change notification settings - Fork 11
Colorbar params from docs yield errors #181
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
Comments
The docs would suggest that you could do cmap = uplt.Colormap("plasma_r")
fig, axs = uplt.subplots(nrows=1, ncols=2)
cbar = fig.colorbar(
cmap,
loc="bottom",
label="My Label",
labelloc="right",
frameon=False,
)
cbar.set_label("My Label", rotation=45)
uplt.show(block=1) But I see that that produces an error. In the codebase I can see that it indeed does not handle the frame on -- even though it is listed (see https://ultraplot.readthedocs.io/en/latest/api/ultraplot.figure.Figure.html#ultraplot.figure.Figure.colorbar). I have another commit where you can toggle the spines with one command but it is currently private (and not merged yet) I could make it public to handle this and then incorporate it within the colorbar. All the issues raised are valid and should be incorporated. I do have, however, another 6 ish PRs that need merging and reviewing. In short, this will go on the todos and should not be a big deal to implement. |
Btw the code you are looking for is (for now) import ultraplot as uplt
cmap = uplt.Colormap("plasma_r")
fig, axs = uplt.subplots(nrows=1, ncols=2)
cbar = fig.colorbar(
cmap,
loc="bottom",
label="My Label",
labelloc="left",
)
cbar.set_label("My Label", rotation=0, ha = "left")
cbar.outline.set_visible(False)
uplt.show(block=1) |
@ToryDeng in case you or somebody else wants to tackle this. This may be quicker for development as you seem to be very good at finding bugs 😉. What needs to be done is that the docstring for colorbar would need to match the internal processing. This would require going through both to see which ones are missing and add those appropriately. I have been meaning to refactor colorbar but that can be done in a separate PR. Appropriate tests would need to be added to validate the settings, finalized with an image comp. |
I actually was less work than I initially thought. Wasn't thinking clearly yesterday. The input parameters work. The docs state that framealpha is only there fore inset colorbars. I added a PR that allows setting the outline. Please see #189. |
Fixed in main. |
From the example you provided, I know I can modify the rotation and alignment of the colorbar's label and remove the spines of the colorbar's axes by manually creating a colorbar. However, I still want to know if there is a more convenient way to modify these properties in
UltraPlot
.An example is:
The title of the second color bar is easier to read and will not overlap with the xticklabels.
The text was updated successfully, but these errors were encountered: