Shiny 仪表板中集成的 Plotly 图形的大小和比例会在最大化屏幕时发生变化
The size and scale of Plotly graph integrated in Shiny dashboard would change when maximizing screen
我正在 Shiny 仪表板中集成一个绘图。但是,在最大化屏幕或将 UI 拖到具有不同分辨率的屏幕后,图表的大小和比例将更改为。
吹的是我要的图的截图:
下图为最大化屏幕后的图形截图:
下面是我的代码:
header <- dashboardHeader(
)
sidebar <- dashboardSidebar(
)
body <- dashboardBody(
box(title = "Test",
plotlyOutput("plot")
)
)
ui <- dashboardPage(header, sidebar, body)
server <- function(input, output) {
output$plot <- renderPlotly({
plot_ly(x = b1image$CNT, y = b1image$Label, type = 'bar', orientation = 'h',
marker = list(color = viridis::viridis_pal(option = "C", direction =1)(max(b1image$Label) - min(b1image$Label) + 3)))
})
}
shinyApp(ui, server)
我用来绘制的数据来自名为 b1image 的数据框。
提前致谢。
也许这可以帮到你:
header <- dashboardHeader(
)
sidebar <- dashboardSidebar(
)
body <- dashboardBody(
box(title = "Test", width = 10, height = "500px",
plotlyOutput("plot",width = "400px", height = "400px")
)
)
ui <- dashboardPage(header, sidebar, body)
server <- function(input, output) {
output$plot <- renderPlotly({
server <- function(input, output) {
output$plot <- renderPlotly({
p <- plot_ly()
p <- add_trace(p, x=a, y=b, z=c, mode="markers", type="scatter3d", marker = list(size = 5, color = 'rgba(0, 0, 0, 1)'))
p <- layout(p, scene = list(xaxis = list(title = "A",range = c(-2,2)), yaxis = list(title = "B",range = c(-2,2)), zaxis = list(title = "C",range = c(-2,2))))
p
})
}
shinyApp(ui, server)
})
}
shinyApp(ui, server)
box(title = "Test", width = 10, height = "500px",
plotlyOutput("plot",width = "400px", height = "400px")
)
- 定义框的宽度和高度
定义绘图的宽度和高度
p <- layout(p, scene = list(xaxis = list(title = "A",range = c(-2,2)), yaxis = list(title = "B",range = c(-2,2)), zaxis = list(title = "C",range = c(-2,2))))
定义轴的绘图范围
我正在 Shiny 仪表板中集成一个绘图。但是,在最大化屏幕或将 UI 拖到具有不同分辨率的屏幕后,图表的大小和比例将更改为。
吹的是我要的图的截图:
下图为最大化屏幕后的图形截图:
下面是我的代码:
header <- dashboardHeader(
)
sidebar <- dashboardSidebar(
)
body <- dashboardBody(
box(title = "Test",
plotlyOutput("plot")
)
)
ui <- dashboardPage(header, sidebar, body)
server <- function(input, output) {
output$plot <- renderPlotly({
plot_ly(x = b1image$CNT, y = b1image$Label, type = 'bar', orientation = 'h',
marker = list(color = viridis::viridis_pal(option = "C", direction =1)(max(b1image$Label) - min(b1image$Label) + 3)))
})
}
shinyApp(ui, server)
我用来绘制的数据来自名为 b1image 的数据框。
提前致谢。
也许这可以帮到你:
header <- dashboardHeader(
)
sidebar <- dashboardSidebar(
)
body <- dashboardBody(
box(title = "Test", width = 10, height = "500px",
plotlyOutput("plot",width = "400px", height = "400px")
)
)
ui <- dashboardPage(header, sidebar, body)
server <- function(input, output) {
output$plot <- renderPlotly({
server <- function(input, output) {
output$plot <- renderPlotly({
p <- plot_ly()
p <- add_trace(p, x=a, y=b, z=c, mode="markers", type="scatter3d", marker = list(size = 5, color = 'rgba(0, 0, 0, 1)'))
p <- layout(p, scene = list(xaxis = list(title = "A",range = c(-2,2)), yaxis = list(title = "B",range = c(-2,2)), zaxis = list(title = "C",range = c(-2,2))))
p
})
}
shinyApp(ui, server)
})
}
shinyApp(ui, server)
box(title = "Test", width = 10, height = "500px",
plotlyOutput("plot",width = "400px", height = "400px")
)
- 定义框的宽度和高度
定义绘图的宽度和高度
p <- layout(p, scene = list(xaxis = list(title = "A",range = c(-2,2)), yaxis = list(title = "B",range = c(-2,2)), zaxis = list(title = "C",range = c(-2,2))))
定义轴的绘图范围