相关,但一般只讨论分配的打印空间,而不是如何直接设置打印图像大小并将其zoom then以填充所需的空间
我正在创建一个shiny 的web应用程序,并想设置plot and比例的大小.我的意思是,我正在寻找一种方法,为我的绘图设置有限的高度/宽度,并将大小为mainPanel( plotOutput ())
的图像设置为then比例.
以这为例/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
我想控制图像本身的大小,因为我发现使用colour = var
和size = var
这样的选项时,ggplot2
个图例非常小.请注意,在大图中读取轴标签也很困难.我意识到我可能会遇到这样的情况:由于像素有限,图像的大小不能很好地zoom ,但我认为在遇到这种情况之前,我至少有some个空间可以移动.
有什么建议吗?到目前为止,我已经try 过玩以下游戏,但运气不佳:
用户界面.R
shinyUI(pageWithSidebar(
headerPanel("Title"),
sidebarPanel(),
mainPanel(
plotOutput(outputId = "main_plot", width = "100%"))
))
服务器R
shinyServer(function(input, output) {
x <- 1:10
y <- x^2
output$main_plot <- renderPlot({
plot(x, y) }, height = 400, width = 600 )
} )
服务器R
中指定的高度/宽度选项似乎覆盖了我在用户界面.R
的plotOutput
部分中设置的任何选项.
有没有办法使绘图图像的大小保持较小,以保持可读性,同时仍填充所需的mainPanel
区域?