Lalikus
January 27, 2022, 11:13am
1
Hello everyone,
I wonder if it is possible to move the ticks of the colorbar to left part of the plot.
Graphical example:
empet
January 27, 2022, 5:48pm
2
@Lalikus
Yes, you can put ticklabels at leftl, setting colorbar_ticklabelposition
:
layout.coloraxis | Python | Plotly .
The solution above is incorrect. The ticklabelposition
settings "outside left"
and "inside left"
only denote the position of the label relative to the tick and can only be used when orientation
is "h"
- i.e., when the colorbar is horizontal.
Currently, I donβt think thereβs a way to put the labels on the left side of a colorbar.
ozhang
March 8, 2023, 6:14pm
4
Seems not implemented yet:
opened 08:46PM - 14 Mar 22 UTC
Please, enable the **tick labels for colorbars to be placed to the left of a ver⦠tical colorbar** (or, an equivalent, **on top when a colorbar is horizontal**) - as, for example, suggested in the following forum question (the "solution" to which I believe is incorrect):
https://community.plotly.com/t/colorbar-ticks-left-aligned/60473
Positioning to the right works in most scenarios but there are plenty of use cases where the labels would be more desirable to the left - for example, when the labels are numbers with varying orders of magnitude, in which case this would allow to align them by the decimal point.
As an example of badly aligned numbers to the right of a colorbar, see the plot below, which is the second plot under the heading "Setting the Midpoint of a Diverging Color scale with Graph Objects" here:
https://plotly.com/python/colorscales/
Before:

After:

Alternatively, or in addition to this feature, it would be great to be able to **right-align the labels**, regardless of which side of the colorbar they are placed on.
But found a workaround:
Place tick labels inside colorbar - ticklabelposition
Put enough spaces as tick suffix to push-out labels to the left - ticksuffix
Allow label overflow to show first and last tick labels - ticklabeloverflow
Define font color as it is turned to white when put inside colorbar - tickfont_color
To accordingly update a figure:
fig.update_traces(
colorbar=dict(
ticklabelposition='inside',
ticksuffix=' ',
ticklabeloverflow='allow',
tickfont_color='darkslategrey',
),
)