Nat*_*ith 23 plot r centering shiny
我有一个fluidRow,其中一个列在一个列中呈现.我想知道当我通过renderPlot({create plot here},width = ##)函数手动指定绘图宽度时如何使绘图居中(因此,它不占用列的整个宽度) .
ui.R代码:
setwd("C:/Users/Nate/Documents/R Working Directory/appFolder/example")
shinyUI(fluidPage(
titlePanel("Test"),
sidebarLayout(
sidebarPanel(
p('stuff here')
),
mainPanel(
tabsetPanel(id = 'tabs1',
tabPanel("main",
fluidRow(
column(8,
plotOutput('plot1')),
column(4,
p('2nd column'))),
fluidRow(
p("2nd row of viewing area"))
),
tabPanel("second",
p("main viewing area")),
tabPanel("third",
p('main viewing area')
)
))
)
))
Run Code Online (Sandbox Code Playgroud)
server.R代码:
shinyServer(function(input, output, session) {
output$text1 = renderText({
paste("text output")
})
output$plot1 = renderPlot({
x = runif(10,0,10)
y = rnorm(10)
plot(x,y)
}, width = 300)
})
Run Code Online (Sandbox Code Playgroud)
Ewe*_*wen 49
align="center"可以包含在column表达式中(不在其中plotOutput).例如
fluidRow(
column(8, align="center",
plotOutput('plot1')
)
)
Run Code Online (Sandbox Code Playgroud)
GK8*_*K89 -6
您可以将其用作align="center"您的功能的一部分plotOutput()。所以你的 ui.R 会喜欢这样:
ui.R
setwd("C:/Users/Nate/Documents/R Working Directory/appFolder/example")
shinyUI(fluidPage(
titlePanel("Test"),
sidebarLayout(
sidebarPanel(
p('stuff here')
),
mainPanel(
tabsetPanel(id = 'tabs1',
tabPanel("main",
fluidRow(
column(8,
plotOutput('plot1',align="center")),
column(4,
p('2nd column'))),
fluidRow(
p("2nd row of viewing area"))
),
tabPanel("second",
p("main viewing area")),
tabPanel("third",
p('main viewing area')
)
))
)
))
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
22681 次 |
| 最近记录: |