Ich versuche, den Titel der Farbleiste in einem plotly Streudiagramm ändern.Ändern Plotly Colorbar Titel
Mit Blick auf die Dokumentation scheint es, dass dies trivial sein sollte. Ich habe jedoch versucht, colorbar = list(title = "Typing Rate")
sowohl in den Hauptcode plotly()
zu stecken, als auch in layout()
, wie unten verrohrt.
Wie kann ich diesen Titel anpassen?
library(dplyr)
library(shiny)
library(plotly)
df <- as.data.frame(list("UserID"=c(1,1,1,1,2,2,2,2),
"Category"=c('A','A','B','B','A','A','B','B'),
"Rate"=c(2,3,5,6,8,6,7,1),
"x"=c(1,3,5,7,2,4,6,8),
"y"=c(1,3,5,7,2,4,6,8)
))
ui <- (fluidPage(
sidebarLayout(
sidebarPanel(
selectInput("userInput","Select User", sort(unique(df$UserID)),
selected=1),
checkboxGroupInput("CategoryInput", "Select Category", sort(unique(df$Category)),
selected=c('A','B'))
),
mainPanel(
plotlyOutput("mainPlot")#,
)
)
))
server <- function(input, output, session) {
# filter for both user and category
filteredFull <- reactive({
df %>%
filter(
UserID == input$userInput,
Category %in% input$CategoryInput
)
})
output$mainPlot <- renderPlotly({
plot_ly(data=filteredFull(), x=x, y=y,
color=Rate, size=Rate,
mode='markers') %>%
layout(
colorbar = list(title = "Typing Rate")
)
})
}
shinyApp(ui, server)
Wow, so dass funktioniert! Irgendeine Idee warum? Hypothetisch scheint es, als ob es dasselbe sein sollte wie in 'plot_ly()' –