Я использую R-плотно и блестяще. Следующим шагом я хочу создать параметр 2x, 2y, подобный этому изображению image1
Но сначала я хочу знать, как отобразить имя оси x
Это моя таблица данных CSV, которую я пытаюсь сделать (https://drive.google.com/drive/folders/1wyFhQ9izcjsVnwqI4cedNtz9vwLQzV1N?usp=sharing)
---- R code ----
data <- data.frame(Month,Cities,Accident,Robberies)
layout(
title = "test drop down",
paper_bgcolor='rgb(255,255,255)',
plot_bgcolor='rgb(229,229,229)',
xaxis = list(tickangle = -45),
yaxis = list(),
)
ui <- fluidPage(
titlePanel("BABABA BABANANA"),
sidebarLayout(
sidebarPanel(
selectInput("var_y1",
label = "Choose a Y1-axis ",
choices = c("ACC",
"ROB"),
selected = "ACC"),
selectInput("var_y2",
label = "Choose a Y2-axis ",
choices = c("ACC",
"ROB"),
selected = "ROB"),
selectInput("var_x1",
label = "Choose a X1-axis ",
choices = c("MONTH",
"Cities"),
selected = "Cities"),
selectInput("var_x2",
label = "Choose a X2-axis ",
choices = c("MONTH",
"Cities"),
selected = "MONTH"),
sliderInput("slider2",
label = "Range of interest:",
min = 0, max = 100, value = c(0, 100)),
br(),
actionButton("close", "Click to disconnect")
),
mainPanel(
plotlyOutput("selected_var"),
textOutput("min_max")
)
),
hr(),
fluidRow(
column(4, verbatimTextOutput("value")),
column(4, verbatimTextOutput("range"))
)
)
server <- function(input, output) {
observeEvent(input$close, {
stopApp()
})
output$selected_var <- renderPlotly({
r <- plot_ly(data,x1 = ~Cities,x2 = ~Month,y = ~Accident,name = 'Accident/Month', type = 'scatter', mode = 'lines+markers', line = list(shape = "spline"))
s <- plot_ly(data,x1 = ~Cities,x2 = ~Month,y = ~Robberies,name = 'Robberies/Month', type = 'scatter', mode = 'lines+markers', line = list(shape = "spline"))
if(input$var_y1 == "ACC"){
r
}
else if(input$var_y1 == "ROB"){
s
}
})
output$min_max <- renderText({
paste("You have chosen a range that goes from ",
input$slider2[1]," to ", input$slider2[2])
})
}
shinyApp(ui = ui, server = server)