将ggsave()宽高比设置为RStudio的“缩放"比例.按钮给? [英] Set ggsave() aspect ratio to the ratio that RStudio's "Zoom" button gives?

查看:121
本文介绍了将ggsave()宽高比设置为RStudio的“缩放"比例.按钮给?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 ggsave() ggplot()保存图.

在R-Studio中,单击缩放"按钮会自动将大多数绘图的大小调整为具有相当的美学比例,而当我尝试手动指定尺寸和宽高比时,会得到看起来不太好的绘图.

In R-Studio, clicking the "Zoom" button automatically resizes most of my plots to have quite aesthetic proportions, whereas when I try to manually specify the size and aspect ratios, I get plots that don't look as nice.

有没有一种方法可以使ggsave使用与R-Studio的缩放"按钮相同的长宽比或大小?

Is there a way that I can make ggsave use the same aspect ratio or size that R-Studio's "Zoom" button does?

或者如何使用代码调用缩放"按钮?

Or how do I call the Zoom button using code?

推荐答案

如果右键单击缩放的图像并选择检查元素",则将在其中看到长宽比.然后可以将其传递给ggsave.请注意,我假设R Studio的缩放比例选择的宽高比在给定的显示器上是恒定的,在这种情况下,您只需要查找一次宽高比即可.

If you right click on the zoomed image and select 'Inspect element', you'll see the aspect ratio there. That can then be passed into ggsave. Note that I'm assuming the aspect ratio selected by R Studio's zoom is constant on a given monitor in which case you would only need to find the aspect ratio once.

这是在哪里找到它的示例.

这篇关于将ggsave()宽高比设置为RStudio的“缩放"比例.按钮给?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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