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

bug: unexpected behavior of inset colorbar #336

Open
syrte opened this issue Feb 8, 2022 · 2 comments
Open

bug: unexpected behavior of inset colorbar #336

syrte opened this issue Feb 8, 2022 · 2 comments

Comments

@syrte
Copy link

syrte commented Feb 8, 2022

Description

Unexpected behavior of inset colorbar with keywords tickloc and labelloc.

Steps to reproduce

The code below

import proplot as pplt
import numpy as np

fig, axes = pplt.subplots(None, 1, 2)
cm = axes[0].scatter(*np.random.rand(4, 10), vmin=0, vmax=1)

axes[0].colorbar(cm, loc='ll', length=10, width=0.8, label='abc', tickloc='top')
axes[1].colorbar(cm, loc='ll', length=10, width=0.8, label='abc', labelloc='top')

gives this

image

If I understand correctly,
left panel: we would expect the ticks shown at the top when tickloc='top' is set.
right panel: strange padding when placing the label on the top.

I tried to fix the padding in the right panel, it turns out not easy for me ...

Proplot version

Paste the results of import matplotlib; print(matplotlib.__version__); import proplot; print(proplot.version)here.

3.4.3
0.9.5.post284
@lukelbd
Copy link
Collaborator

lukelbd commented Feb 8, 2022

Yeah... the inset colorbar implementation is unfortunately just very flimsy right now. I'm working on a fix in #311 that will automatically adjust the position of the colorbar axes and frame using its tight bounding box. Have already done the hard part (figured out how to auto-anchor an axes and adjust a background frame), just have to integrate with ax.colorbar().

Will try to merge #311 before the next release (.....sometime this month) because I'm uncomfortable publishing a new release with such fragile behavior. It was under-tested in previous versions.

@syrte
Copy link
Author

syrte commented Feb 8, 2022

Thank you Luke for the hard work! Look forward to the fix.

BTW, one more example about incorrect padding (too large) in the third panel below. From your description, I guess auto-anchor things would fix this behavior as well ;)

Also another strange behavior, note the location of label in the middle panel, it has been changed when plotting the right panel. If I use different cm objects, then it would be at the correct location as in the previous figure.

image

Code

import proplot as pplt
import numpy as np

fig, axes = pplt.subplots(None, 1, 3)
cm = axes[0].scatter(*np.random.rand(4, 10), vmin=0, vmax=1)

axes[0].colorbar(cm, loc='ll', length=10, width=0.8, label='abc', tickloc='top')
axes[1].colorbar(cm, loc='ll', length=10, width=0.8, label='abc', labelloc='top')
axes[2].colorbar(cm, loc='ll', length=10, width=0.8, label='abc', labelsize='x-small', ticklabelsize='x-small')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants