2017-08-03 157 views
5

在jupyter筆記本中使用R,首先我通常設置繪圖大小。其次,我想繪製一個不同大小的單一情節。R - 在jupyter中更改ggplot繪圖大小

## load ggplot2 library 
library("ggplot2") 
## set universal plot size: 
options(repr.plot.width=6, repr.plot.height=4) 

## plot figure. This figure will be 6 X 4 
ggplot(iris, aes(x = Sepal.Length, y= Sepal.Width)) + geom_point() 

## plot another figure. This figure I would like to be 10X8 
ggplot(iris, aes(x = Sepal.Length, y= Sepal.Width)) + geom_point() + HOW DO i CHANGE THE SIZE? 

正如你可以看到,我想改變第二個圖(只有第二個圖)是一個10×8。我該怎麼做呢?

對不起,有一個潛在的問題,因爲繪圖大小在Rstudio中通常不是問題。

回答

4

在這裏你去:

library(repr) 
options(repr.plot.width=10, repr.plot.height=8) 
ggplot(iris, aes(x = Sepal.Length, y= Sepal.Width)) + 
    geom_point() 
+0

'庫(再版)'一部分是不必要的,我 – eddi