ggplotly() doesn't support multiple colors in axis ticks
Nobody has claimed this yet.
- Dominant language
- R
- Stars
- 2.7k
- Forks
- 641
- PR merge metrics
- No merged PRs in 30d
Description
Hello and thanks for the great job you did by making this really useful package. I just want to report an issue that appears when I need to colour the axis text of a plot with pre - defined colours. Below you can see the R code to build a really simple shiny app. If I plot my graph with the standard ggplot() function the names of the x axis result colored, but if I use the function ggplotly() to make my plot interactive, the text of the x axis remains black (the functions recognizes the arguments "angle" and "hjust" but not "col").
Thanks in advance for the availability.
Nico
library(ggplot2)
library(plotly)
library(shiny)
### UI
ui <- fluidPage(
fluidRow(
column(width = 8,
plotlyOutput(outputId = "plot",
height = "600px"))))
### SERVER
server <- function(input, output) {
output$plot <- renderPlotly({
mpg_s <- mpg[c(1, 19, 38), ] # subset to pick just 3 rows
col <- c("red", "green", "blue")
p <- ggplot(data = mpg_s,
aes(x = manufacturer, y = hwy)) +
geom_point() +
theme(axis.text.x = element_text(size = 20,
angle = 90,
hjust = 1,
colour = col))
ggplotly(p)
})
}
### LUNCH APP
shinyApp(ui = ui, server = server)
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
The issue provides a reproducible ggplotly(p) example in a Shiny app but names no repository files or tests. Start by tracing how ggplotly converts ggplot2 axis.text.x settings, then compare the ggplot and interactive outputs; done means predefined colors appear on the interactive x-axis tick labels.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- r
- Domain
- data-visualization
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100