plotly / plotly/plotly.R

annotation_custom in ggplot not supported by plotly

Open
#1,988 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
R
Stars
2.7k
Forks
641
PR merge metrics
No merged PRs in 30d

Description


Hi all,
I have a line of code to draw a rectangle, with a gradient color scheme, onto a ggplot figure using annotation_custom. However, this is not supported (and does not appear) when I make my figure interactive with ggplotly.

I am having trouble finding another solution for making this same shape that appears in the static figure in the interactive figure. Is there a way that ggplotly can support custom annotations?
Thank you!

g <- rasterGrob(matrix(c(bluepal), nrow = 1), 
                                 width=unit(1,"npc"), height = unit(1,"npc"), 
                                 interpolate = TRUE) #make a gradient of blue colors 

annotation_custom(g, xmin=2.7, xmax=7.5, ymin=20, ymax=22)
<img width="379" alt="Screen Shot 2021-08-12 at 6 17 45 PM" src="https://user-images.githubusercontent.com/22037535/129281870-c665dea2-0c82-4818-86e2-24d311578342.png">


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 by reproducing the supplied R example using rasterGrob, annotation_custom, and ggplotly, comparing the static ggplot with the interactive result. Determine whether custom annotations can be supported and verify that the gradient rectangle appears in the interactive figure.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
data-visualization
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.