ggplotly() creates a wrong legend in some cases
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- r
- Domain
- data-visualization
Research direction
Start by running the reproducible R example from the issue and compare the ggplot2 and ggplotly legends. Investigate the ggplotly conversion of manual colour scales and verify that the converted legend matches the declared Left and Center labels without extra entries.
Written by the indexing model from the issue text.
Description
Given
library(ggplot2)
library(plotly)
d1 <- data.frame(X=1:10, Y= (1:10)^2, b=paste0("B",1:10),d="d1")
d1$Y2 <- d1$Y+2
gg2 <- ggplot(data=d1, aes(label=b)) +
geom_point(aes(x=X, y=Y, col="blue")) +
geom_line(aes(x=X, y=Y2, col="orange")) +
scale_color_manual(values=c("blue","orange"),
labels=c("Left","Center"),
name="")
print(gg2) results in:
But
ggplotly(gg2)
results in:
I know a more conventional code such as:
d1 <- data.frame(X=1:10, Y= (1:10)^2, b=paste0("B",1:10),position="left")
d2 <- data.frame(X=1:10, Y= (1:10)^2 + 2, b=paste0("B",1:10),position="center")
d <- rbind(d1,d2)
gg2 <- ggplot(data=d, aes(label=b)) +
geom_point(data=d[d$position=="left",],aes(x=X, y=Y,col=position)) +
geom_line(data=d[d$position=="center",],aes(x=X, y=Y,col=position)) +
scale_color_manual(values=c("blue","orange","red"),
labels=c("Left","Center"),
name="")
gg2
ggplotly(gg2)
results in similar legends, but I wonder if the 1st example is not uncovering a bug in ggplotly()
- Dominant language
- R
- Stars
- 2.7k
- Forks
- 641
- PR merge metrics
- No merged PRs in 30d
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.
More from plotly/plotly.R
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
-
Difficulty 3/5 1-2 days Newbie friendliness 68/100
-
Difficulty 3/5 1-2 days Newbie friendliness 72/100
-
save_image Error Open
Difficulty 3/5 1-2 days Newbie friendliness 52/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
easystats/performance#950 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
briandconnelly/airnow#9 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
OHDSI/CohortConstructor#774 ·