मैं r
में plotly
का उपयोग कर रहा हूं ताकि कई सबप्लॉट उत्पन्न हो सकें। एक खिलौना उदाहरण नीचे दिखाया गया है।सबप्लॉट्स के लिए प्लॉटली लीजेंड ग्रुप इसलिए एक एकल किंवदंती सभी चार्टों को नियंत्रित करता है
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)
मैं किंवदंतियों ऐसी है कि पर एक पौराणिक कथा पर 'कट' पर क्लिक दिखाएगा/बनाने के लिए चाहते हैं छिपाने कि दोनों के बजाय सिर्फ इतना है कि कथा के साथ जुड़े चार्ट चार्ट से 'कट'।
मैं legendgroup को देखा लेकिन समझ नहीं कैसे cut
बजाय clarity
से संबद्ध करना (clarity
समूहीकरण मैं subplots बनाने के लिए उपयोग कर रहा हूँ है)।
मैं भी समाधान वहाँ अन्य plot_ly
कार्यक्षमताओं मैं की जरूरत है कि ggplotly
में उपलब्ध नहीं हैं के रूप में नहीं ggplotly
कच्चे plot_ly
साथ काम करते हैं और की जरूरत है।
किसी भी मदद की सराहना की जाएगी। मैं plotly_4.5.2
, dplyr_0.5.0
, और shiny_0.14
का उपयोग कर रहा हूं।
आप plotly 4.0 के तहत कोशिश 'बेहतर अभ्यास और इस जवाब में above.' किया: ' https://stackoverflow.com/a/41122127/2296728 ' – urwaCFC