R-在Jupyter中更改ggplot绘图大小 [英] R - Changing ggplot plot size in jupyter

查看:339
本文介绍了R-在Jupyter中更改ggplot绘图大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,在Jupyter笔记本电脑中使用R,我会通用设置绘图大小.其次,我想绘制一个具有不同大小的绘图.

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.

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

如您所见,我想将第二个绘图(并且仅第二个绘图)更改为10X8.我该怎么做?

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?

很抱歉可能会有一个愚蠢的问题,因为在Rstudio中,绘图大小通常不是问题.

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

推荐答案

在这里:

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

这篇关于R-在Jupyter中更改ggplot绘图大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆