英文:
How to resize an R plot in the report generated by compile report (Not in R Markdown)?
问题
在R Studio中,有一个选项可以在R Markdown中不编写代码的情况下编译报告。在Mac上的键盘组合是Shift + Command + K。当我在下面的代码中使用它时:
par(mfrow = c(2,1))
plot(pressure$pressure~pressure$temperature)
curve((0.168 + 0.007*x)^(20/3), from = 0, to = 400, add = TRUE)
mtext("Temperature vs. Pressure (Unadjusted)", side = 3, cex = 1.2)
plot(pressure$pressure^(3/20)~pressure$temperature)
abline(0.168,0.007)
mtext("Temperature vs. Pressure (Adjusted)", side = 3, cex = 1.2)
它会生成类似这样的报告:
有没有办法调整报告中的图的大小?例如,如何设置宽度为 800,高度为 1000,就像下面的图片一样?
英文:
In R Studio, there is an option to compile a report without writing codes in the R Markdown. The keyboard combination on Mac is Shift + Command + K. When I use it on the following code:
par(mfrow = c(2,1))
plot(pressure$pressure~pressure$temperature)
curve((0.168 + 0.007*x)^(20/3), from = 0, to = 400, add = TRUE)
mtext("Temperature vs. Pressure (Unadjusted)", side = 3, cex = 1.2)
plot(pressure$pressure^(3/20)~pressure$temperature)
abline(0.168,0.007)
mtext("Temperature vs. Pressure (Adjusted)", side = 3, cex = 1.2)
Is there a way to resize the plot in the report? For example, how to set it to width 800, and height 1000 as in the following image?
答案1
得分: 1
你可以使用特殊注释(类似于块选项)来设置图的宽度和高度,例如:
#+ fig.height = 10.4, fig.width = 8.3
在你创建绘图的位置上方。请注意,这里图的尺寸始终以英寸为单位(不同于你的示例中的像素),因此你需要从像素转换为英寸。
英文:
You can set the figure width and height using special comments (similar to chunk options) e.g.
#+ fig.height = 10.4, fig.width = 8.3
above where you create the plot. Note that here the figure sizes are always given in inches (not pixels as in your example, so you would need to convert from pixels to inches).
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论