-
Notifications
You must be signed in to change notification settings - Fork 7
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
minorticks cannot be setted in colorbar #95
Comments
Hi there, thanks for reporting. Please provide a minimal reproducible example -- it is hard to tell what the intentions are based on the snippets. I had a quick peek at the code to see what's going on. The levels will set the space of colors that you can extract from the import ultraplot as plt
import numpy as np
x = np.random.rand(10, 10)
fig, ax = plt.subplots()
ticks = np.linspace(0, 10)
y = np.array([0, 2, 10])
m = ax.contourf(x, x, x, levels=y, extend="both")
cb = ax.colorbar(m)
fig.show() will produce a plot in which the levels are indicated by If I would then set the ticks, it will attempt to fill the range set by x = np.random.rand(10, 10)
fig, ax = plt.subplots()
ticks = np.linspace(0, 10)
y = np.array([0, 2, 10])
m = ax.contourf(x, x, x, levels=y, extend="both")
cb = ax.colorbar(m, ticks = ticks)
fig.show() This is behaving a it should I think, but I could be misinterpreting what you mean. |
Thank you! Take the demo in the documentation as an example (https://ultraplot.readthedocs.io/en/latest/colorbars_legends.html#Figure-wide-colorbars-and-legends). import ultraplot as uplt
import numpy as np
state = np.random.RandomState(51423)
fig, axs = uplt.subplots(ncols=3, nrows=3, refwidth=1.4)
for ax in axs:
m = ax.pcolormesh(
state.rand(20, 20), cmap="grays", levels=np.linspace(0, 1, 11), extend="both"
)
fig.format(
suptitle="Figure colorbars and legends demo",
abc="a.",
abcloc="l",
xlabel="xlabel",
ylabel="ylabel",
)
#fig.colorbar(m, label="column 1", ticks=0.5, loc="b", col=1)
#fig.colorbar(m, label="columns 2 and 3", ticks=0.2, loc="b", cols=(2, 3))
fig.colorbar(m, label="stacked colorbar", ticks=0.1, loc="b", minorticks=0.05)
#fig.colorbar(m, label="colorbar with length <1", ticks=0.1, loc="r", length=0.7) The minorticks in the colorbar of the figure is not 0.05, but 0.1, as showing in the following image. When I use proplot, it's correct. |
Can you checkout the PR
|
The changes in the locator-fix branch resolve the issue effectively. |
Fixed in main. |
The minorticks cannot be correctly setted in the colorbar.
m=ax.contourf(x1,t1,z,levels=np.linspace(0,500,200),extend='both')
ax.colorbar(m,ticks=np.arange(0,501,100),minorticks=20)
The minorticks in the plot are not 20, but depend on the "levels".
The text was updated successfully, but these errors were encountered: