如何在 Jupyter 中更改 R 图的大小? [英] How to change the size of R plots in Jupyter?

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

问题描述

我想知道如何配置 Jupyter 以在 R 内核中绘制更小的图形.

I am wondering how to configure Jupyter to plot a smaller figure within R kernel.

我尝试使用 options(repr.plot.width = 1, repr.plot.height = 0.75, repr.plot.res = 300),但结果有点乱.它正在改变生成的图 R 的大小.有什么方法可以直接在 Jupyter 中配置输出图的大小.

I have tried using options(repr.plot.width = 1, repr.plot.height = 0.75, repr.plot.res = 300), but the result is kinda messy. It is changing the size of the plot R produced. Are there any ways I can directly configure the output graph size in Jupyter.

换句话说,如何将第一个图中的大小更改为第二个图中的大小,同时又不会弄乱情节.

In other words, how can I change the size in the first figure to the size in the second figure, while not messing up the plot.

推荐答案

您需要手动设置刻度大小、标记大小和文本大小.文本大小和刻度大小可以通过theme() 函数设置,而标记大小可以通过geom_point() 函数设置.

You need to manually set the tick size, marker size and text size. The text size and tick size can be set through the theme() function, while marker size through geom_point() function.

df_1 = data.frame(x=c(5, 6, 7, 8, 9), y = c(200, 225, 250, 270, 310))

options(repr.plot.width = 1, repr.plot.height = 0.75)
ggplot(df_1, aes(x = x, y = y)) + geom_point(size = 0.3) + 
   theme(text = element_text(size = 3), element_line(size = 0.1))

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

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