plotly.js icon indicating copy to clipboard operation
plotly.js copied to clipboard

[Feature request] Allow annotations and layout images to be positioned relative to the container, not just the x/y axes or plotting area

Open kburchfiel opened this issue 1 month ago • 2 comments

One thing I really appreciate about title positioning in Plotly is that I can set title locations relative to the container, not just the plotting area or x axis, via the title_xref and title_yref settings. This makes it much easier to achieve consistent title placement across different charts, as many different factors can change the shape of the plotting area.

Would it be possible to add container as an xref and yref option for annotations and images also? I've been needing to manually adjust these across charts, which can take a decent amount of time. (For PNG exports, I can achieve consistent placements by adding them in via Pillow, but this won't help for HTML-based charts.)

Also, one somewhat-related question (which I'm happy to move to a separate issue if needed): Is there a way to ensure that an image will always be the same size, in pixels, as long as the width of the chart (in pixels) is always the same? It appears that, even when the sizex and sizey settings stay the same, the image size can vary. (Since these values are relative to the chart's area, though, this is probably to be expected. But being able to specify a fixed size, e.g. 300x200px, would be fantastic.)

kburchfiel avatar Nov 26 '25 17:11 kburchfiel

This would be a great feature. We would be very open to community contributions to make this feature happen!

For the question around image sizing - it might be a good idea to ask on the forum since others have probably run into that use-case before. https://community.plotly.com/

robertclaus avatar Dec 03 '25 16:12 robertclaus

Thank you, Robert! My Pillow-based workaround for adding text and logos to PNG exports of Plotly charts has worked well--and has saved me lots of time, as I no longer need to tweak image and annotation locations to get them in the right place. However, I would love to be able to implement a similar approach directly in Plotly so that I can achieve the same consistency with HTML-based charts. I do hope that a community member might be able to make this possible, as I'm sure others would be helped by it as well.

kburchfiel avatar Dec 03 '25 17:12 kburchfiel