相关,但只谈论一般分配的绘图空间,而不是如何直接设置绘图图像大小和then缩放它以填充所需的空间
- 闪亮图表空间分配 https://stackoverflow.com/questions/17204735/shiny-chart-space-allocation
我正在创建一个闪亮的网络应用程序,并且想设置绘图的大小and规模。我的意思是我正在寻找一种方法来为我的绘图设置有限的高度/宽度,并且then缩放将大小图像设置为mainPanel( plotOutput ())
area.
以此为例/外部的类似情况shiny
.
x <- 1:10
y <- x^2
png("~/Desktop/small.png", width = 600, height = 400)
plot(x, y)
dev.off()
png("~/Desktop/big.png", width = 1200, height = 800)
plot(x, y)
dev.off()
我无法将图像上传到 SO 并设置尺寸,因此我将使用以下 html 包含每个图像的浏览器屏幕截图:
<img src="file:///home/jwhendy/Desktop/file.png" width = "800px" />
这是我的 1600 x 900 像素笔记本电脑上的全宽屏幕截图。
Small
Big
我想控制图像本身的大小,因为我发现ggplot2
使用类似选项时的图例colour = var
and size = var
非常小。请注意,阅读大图的轴标签也很困难。我意识到我可能会遇到由于像素有限而图像大小无法很好缩放的情况,但我认为我至少有some在我遇到这种情况之前,有足够的旅行空间。
有什么建议么?到目前为止,我已经尝试过使用以下内容,但没有运气:
ui.R
shinyUI(pageWithSidebar(
headerPanel("Title"),
sidebarPanel(),
mainPanel(
plotOutput(outputId = "main_plot", width = "100%"))
))
server.R
shinyServer(function(input, output) {
x <- 1:10
y <- x^2
output$main_plot <- renderPlot({
plot(x, y) }, height = 400, width = 600 )
} )
似乎指定的高度/宽度选项server.R
覆盖我在中设置的任何内容plotOutput
的部分ui.R
.
有没有办法使绘图图像的大小保持较小以保持可读性,同时仍然填充所需的内容mainPanel
area?