Skip to content

colorbar.make_axes doesn't anchor in constrained_layout #14638

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

Closed
nspies-celsiustx opened this issue Jun 26, 2019 · 1 comment · Fixed by #17494
Closed

colorbar.make_axes doesn't anchor in constrained_layout #14638

nspies-celsiustx opened this issue Jun 26, 2019 · 1 comment · Fixed by #17494
Labels
status: confirmed bug topic: geometry manager LayoutEngine, Constrained layout, Tight layout
Milestone

Comments

@nspies-celsiustx
Copy link

Bug report

Bug summary

There doesn't appear a way to move colorbars up and down when using colorbar.make_axes() in constrained_layout=True mode. The anchor argument appears to be functionally ignored. (Note that location specifies left/right/top/bottom, whereas anchor should move the colorbar within the specified location, eg if the default location of right is chosen, anchor allows moving the colorbar to the top or bottom.)

This appears to be an incomplete implementation of the constrained_layout.layoutcolorbargridspec function, called from here:

https://github.com/matplotlib/matplotlib/blob/c8b92926a880163394e3bd7f56220b65df71646c/lib/matplotlib/_constrained_layout.py

Please let me know if I'm missing something or if there's a workaround.

Code for reproduction

fig, ax = plt.subplots(constrained_layout=True)
ax.scatter(np.arange(100), np.arange(100), c=np.arange(100))
cax, _ = matplotlib.colorbar.make_axes(ax, shrink=0.5, anchor=(0.0, 1.0))
cbar = matplotlib.colorbar.ColorbarBase(cax)

Actual outcome

With constrained_layout=True:
image

Expected outcome

With constrained_layout=True, the anchor argument is honored:
image

(Note that the colorbar has moved to the top, as expected given the anchor=(0, 1.0).)

@jklymak
Copy link
Member

jklymak commented Jun 26, 2019

That should be possible to fix but may be quite complex. Patches welcome!

@jklymak jklymak added the topic: geometry manager LayoutEngine, Constrained layout, Tight layout label May 25, 2020
@QuLogic QuLogic added this to the v3.4.0 milestone Aug 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: confirmed bug topic: geometry manager LayoutEngine, Constrained layout, Tight layout
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants