replicate ggplot2 text legend
Open
Nobody has claimed this yet.
- Dominant language
- R
- Stars
- 2.7k
- Forks
- 641
- PR merge metrics
- No merged PRs in 30d
Description
I'd like to create a legend having text over a point as in the ggplot2 example below. How can I replicate this with plotly. Doesn't need to be a nice and clean ggplotly() solution.
library(ggplot2)
library(plotly)
ds <- data.frame(text = c("+", "-"))
p <- ggplot(ds, aes(x = text, y = text, label = text)) +
geom_point(aes(colour = text), size = 6) +
geom_text(show.legend = TRUE) +
guides(colour = guide_legend(override.aes = list(label = c("-", "+")))) +
scale_colour_discrete(labels = c("minus", "plus"))
p
ggplotly(p)
ggplot2 version

ggplotly version

Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start from the supplied ggplot2 and ggplotly examples, then inspect the plotly.R code responsible for converting legends and text traces. Reproduce a legend with text over points and labels such as “minus” and “plus”; done means the Plotly result visually matches the requested ggplot2 legend behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- r
- Domain
- data-visualization
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100