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

Add xref and yref to colorbars #6593

Merged
merged 16 commits into from
May 12, 2023
Merged

Add xref and yref to colorbars #6593

merged 16 commits into from
May 12, 2023

Conversation

hannahker
Copy link
Contributor

@hannahker hannahker commented May 8, 2023

Summary: Add support for container-referenced positioning for plot colorbars. See demo CodePen here: https://codepen.io/hannahker/pen/eYPMpVV

API changes: yref and xref parameters are added to colorbars.

Expected behaviour:

  • The colorbar may be positioned relative to the full container area if colorbar.yref or colorbar.xref are set to 'container'.
  • If a colorbar has container-referenced positioning, then space will be added to the _fullLayout._reservedMargin accordingly, meaning that colorbars may be automatically positioned to avoid components such as automargined axes.
    • If xref='container', then margin space will be added to the _reservedMargin on the left or the right of a plot area (depending if x > 0.5)
    • If yref='container', then margin space will be added to the _reservedMargin on the top or bottom of a plot area (depending if y > 0.5).
    • If both xref='container' and yref='container', then margin spacing will be added to the top or bottom if orientation='v' and left or right if orientation='h'.

The defaults for yanchor, xanchor, y, and x have also been adjusted for cases where container-referencing is applied.

TODO:

  • Constrain x and y to be within [0, 1] if container referencing is applied.

See #6589 for similar changes applied for legends.

Copy link
Collaborator

@alexcjohnson alexcjohnson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💃 Well done 🎉

@archmoj
Copy link
Contributor

archmoj commented May 12, 2023

💃

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

Successfully merging this pull request may close these issues.

None yet

3 participants