-
Notifications
You must be signed in to change notification settings - Fork 11
Error when setting labelloc='top'
#163
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
I'm using
|
Hi again! The output is a bit cryptic but it is due to how the labels are handled inside matplotlib. For colorbars on the left or right, the allowed sides are I think what you want is to put the label "on top" for a side colorbar. This can be achieved but requires more fiddling: import ultraplot as uplt
import numpy as np
import pandas as pd
state = np.random.RandomState(51423)
data = state.normal(size=(3, 3)).cumsum(axis=0)
data = pd.DataFrame(data, columns=["a", "b", "c"])
kw = {
"length": 0.3,
"label": "LABEL",
"labelcolor": "red",
"loc": "r",
"labelloc": "right",
}
fig, ax = uplt.subplots()
h = ax.heatmap(
data,
cmap="ColdHot",
)
cbar = ax.colorbar(h, **kw)
cbar.ax.set_xlabel("My Label", labelpad=10)
cbar.ax.xaxis.set_label_position("top")
uplt.show(block=1) That being said, I agree that we should address this by allowing a more user friendly control. PR is welcome otherwise I would have to do this somewhere in the future. |
Exactly, and thanks for the solution you have provided! I'll try to submit a pull request to implement this feature when I have time 😄 |
Fixed in main. |
I'm not sure if I did something wrong, but when I try to set the colorbar's label location to
top
, I get an error:So the error info said the supported values are either
left
orright
. But according to the document oflabelloc
, I should be able to usetop
:If I remove this argument, I can plot the colorbar:
The text was updated successfully, but these errors were encountered: