r
içinde plotly
kullanıyorum. Bir oyuncak örneği aşağıda gösterilmiştir.Plotly legendgroup subplots için tek bir lejant tüm grafikleri kontrol eder
library(shiny)
library(dplyr)
library(plotly)
## Toy Example
ui <- fluidPage(
h3("Diamonds"),
plotlyOutput("plot", height = 600)
)
server <- function(input, output, session) {
# reduce down the dataset to make the example simpler
dat <- diamonds %>%
filter(clarity %in% c("I1", "IF")) %>%
mutate(clarity = factor(clarity, levels = c("I1", "IF")))
output$plot <- renderPlotly({
# Generates the chart for a single clarity
byClarity <- function(df){
Clarity <- df$clarity[1];
plot_ly(df, x = ~carat, y = ~price, color = ~cut, name = ~clarity) %>%
add_trace(
type="bar"
## Also tried adding this with no success
# legendgroup = ~cut
) %>%
layout(
barmode = "stack"
)
}
dat %>%
split(.$clarity) %>%
lapply(byClarity) %>%
subplot(nrows = NROW(.), shareX = TRUE, which_layout = "merge")
})
}
shinyApp(ui, server)
Bir efsane 'Cut' tıklayarak/göstereceğine efsaneler böyle yapmak istiyorum hem çizelgeleri yerine o efsane ile ilişkili sadece grafikten 'Kes' olduğunu gizlemek.
clarity
)
cut
yerine
clarity
ile ilişkilendirmek anlamaya olamaz.
Ben de çözüm çiğ plot_ly
ile çalışmak değil, ggplotly
ggplotly
bulunmayan ihtiyacım diğer plot_ly
işlevleri olduğu gibi gerek.
Herhangi bir yardım için teşekkür ederiz. plotly_4.5.2
, dplyr_0.5.0
ve shiny_0.14
kullanıyorum.
sen plotly 4.0 altında 'Daha iyi uygulama denemek ve bu yanıtında above.' mü: ' https://stackoverflow.com/a/41122127/2296728 – urwaCFC