R - 改变jupyter中的ggplot绘图大小

时间:2022-10-22 23:15:47

Using R in a jupyter notebook, first I set the plot size universally. Second, I would like to plot one single plot with a different size.

在jupyter笔记本中使用R,首先我普遍设置绘图大小。其次,我想绘制一个不同大小的单个地块。

## 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?

As you can see, I would like to change the second plot (and only the second plot) to be a 10X8. How do I do this?

如您所见,我想将第二个图(并且只有第二个图)更改为10X8。我该怎么做呢?

Sorry for a potentially dumb question, as plot sizing is typically not an issue in Rstudio.

对于一个可能愚蠢的问题感到抱歉,因为情节大小调整在Rstudio中通常不是问题。

1 个解决方案

#1


5  

Here you go:

干得好:

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

#1


5  

Here you go:

干得好:

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