plotly / plotly/plotly.py

allow aligning hovertext for annotations

Open
#3,583 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

feature P3
Dominant language
Python
Stars
18.8k
Forks
2.8k
Avg merge
16h 26m
Merged PRs (30d)
21

Description

It looks like there is no way to control the text justification for annotation hovertexts. For example:

# Make an background image
f = px.imshow( [[255]*6]*3, origin='lower')

# Add two annotations with hovertext
f.add_annotation( x=1, y=1, text='left', hovertext='Will be left justified<br>*', showarrow=False)
f.add_annotation( x=5, y=1, text='right', hovertext='Will be right justified<br>*', showarrow=False)

# Tighten the plot
f.update_layout( margin={'l':0, 'r':0, 't':0, 'b':0}, coloraxis_showscale=False)

# This will not apply on the annotation hovertext
f.update_layout( hoverlabel_align='left') 

# This does not exist and annotation hovertexts default to auto
# f.update_annotations( hoverlabel_align='left')

f.show()

The image hovertexts will be all properly left-justified, but the annotation hovertexts will default to 'auto', with the left one being left-justified, and the right one being right-justified. Am I missing something, or this is an omission in the tunable options? Is there some other way to force left-justification on the annotation hovertexts? I produce a set of tables that way that look atrocious otherwise.

Thanks!

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 from the annotation APIs shown in f.add_annotation and the hoverlabel_align behavior in f.update_layout, then trace how annotation hovertext options are exposed. Done means annotation hovertexts can receive an explicit alignment setting, including the left and right examples described in the issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
plotly, python
Domain
data-visualization
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 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.