plotly / plotly/plotly.js

Feature request: support `colorbar.title.text` alignment

Open
#7,508 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature P3
Dominant language
JavaScript
Stars
18.3k
Forks
2k
Avg merge
2d 12h
Merged PRs (30d)
28

Description

Reproducible example

Demo 1 : https://codepen.io/Lexachoc/pen/gbaWEPG
Demo 2 with ternary plot: https://codepen.io/Lexachoc/pen/myemoOB

The problem

There is currently no option to configure the colorbar.title.text alignment. It is always left-aligned.

Image

I've seen posts in the forum and on Stackoverflow asking how to do this, but it is not possible:
https://community.plotly.com/t/fine-grained-position-of-a-colorbar-title/43430
https://stackoverflow.com/questions/69581222/how-do-you-center-the-color-scale-as-per-title-on-plotly

Why this is important

Sometimes we have longer title text. Alignment can help us create a better look with nice alignment.
Even if we break the text with <br>, it is still left-aligned.

Imaging to have a ternary plot like below:

Image

Since the colorbar.title.text is left-aligned, we wasted a lot of space on the right side!

If we could adjust the alignment of the colorbar.title.text to that it is right-aligned, illustrated as below:

Image

We can save a lot of space and enlarge the ternary diagram!

Othrewise, the entire colorbar takes up space and makes the main ternary diagram smaller!

It looks crazy, but you should see that it is obviously affected by the colorbar.title.text in the color bar:

Image

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the two linked CodePen reproductions and inspect the existing colorbar title rendering path in plotly.js. The change is complete when colorbar.title.text supports configurable alignment, including the right-aligned use case shown for the ternary plot, without breaking current behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
data-visualization
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.