问题标签 [ggsave]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
2 回答
233 浏览

r - +r +ggplot +jpeg +背景 +透明

我正在尝试创建具有透明背景的绘图的 jpeg。我想在 powerpoint 中使用 jpeg。我无法让透明度发挥作用。当我将 jpeg 插入 ppt 时,它仍然具有白色背景。有我缺少的选项吗?

0 投票
0 回答
503 浏览

r - 为什么 ggsave(..., dpi=300) 没有将图形 psi 更改为 300 而只是增加了图形的维度

我正在学习 ggplot2 并尝试使用 ggsave() 方法将我的情节保存到图片中。我希望我的最终图表为 300 dpi,但无论我如何更改“dpi=”值,我最终得到的只是一个 72 像素/英寸的图表,那么我的代码有什么问题?

之前也试过别人提出的方案,还是得到了72dpi的图:

0 投票
1 回答
102 浏览

r - Create and save a plot for different groups using ggplot for loop from one .csv file

How do I create a loop that will produce and save 45 different line plots based on "Name" in the .csv file?

I have one large .csv file that contains data for 45 different buildings by date. I need to create a line plot for each building that shows the numbers on the y-axis and date on the x-axis.

I tried using a list() for the buildings to use within the loop, but real building names are too complicated for R.

The code below produces 45 identical plots with different titles. Each plot contains all the data, instead of just the data for one building.

These are plots produced: https://i.stack.imgur.com/5HWI3.png

I can't figure out how to limit the data in each plot by individual buildings.

0 投票
1 回答
289 浏览

r - Problems with labs(caption =... in ggplot as well as in ggsave - error "Error in titleGrob"

I am having a very strange problem with my ggplot2 where I am trying to save a graph as a png using ggsave that contains a caption in the labs parameter. When I used a standard example posted on the web to use as a test and simple post to replicate here, I am getting the exact same error simply trying to display the graph - which is very strange it displays on my main code and only has this error with ggsave, but in my test it won't even display the graph.

This is my test code:

And the error I get with the code above is:

geom_smooth() using formula 'y ~ x' Error in titleGrob(label, x, y, hjust = hj, vjust = vj, angle = angle, : unused argument (expand_y = TRUE)

With my ggsave simply:

Warning: Error in titleGrob: unused argument (expand_y = TRUE)

I would be very grateful for some help. I have just updated to the latest version or R and all other packages associated with my code and this hasn't helped.

0 投票
1 回答
47 浏览

r - 如何使用具有所有自定义属性的 ggsave 保存自定义绘图?

我有一个情节,然后我更改了一些默认属性,ggplot例如font face, font color, bold等。但是,当我使用命令或从Rstudio's plot图像打开情节时,包含我所有的自定义属性。

但是,当我使用ggsave它保存绘图时,不会显示和保存图像的所有自定义属性。更具体地说,我保存的图像未显示them().

我的代码如下

使用保存代码ggsave

有没有办法使用ggsave保存原始情节?

0 投票
0 回答
89 浏览

r - 即使 dpi 为 3000,ggsave 也无法导出可读的绘图

使用下面的代码,我试图将 ggplot 保存为 png 文件。虽然 dpi 相当高,但保存的 png 文件甚至不可读。如下图所示,文件窗格中的导出选项提供了更好的分辨率。有没有什么办法解决这一问题?

使用导出选项保存

0 投票
0 回答
97 浏览

r - 保存允许平移和缩放的 ggplot

我正在创建一系列与不同地区相关的小折线图,然后将其保存为 grobs 并绘制到欧洲地图上。我可以将其保存为 png 文件,然后可以仅使用标准 Windows 照片缩放放大保存的图像上的部分。但是这很慢,缩放的图像需要很长时间才能加载。我想知道是否有更好的方法来做到这一点并尝试使用 svgPanZoom 但我无法获得正确的比例以便它们可见,而不是你可以看到轴而不是图形本身,我也不能弄清楚如何保存绘图,以便仍然可以进行平移和缩放。

有谁知道更好的方法来做到这一点?我的代码在下面,但数据集太大而无法发布示例。

完整地图 放大地图部分

0 投票
1 回答
180 浏览

r - 尝试使用 marrangeGrob 和 ggsave 保存绘图列表时出错

尝试以这种方式将绘图列表保存在一个 pdf 中时出现错误:

其中“地块”是 2 个地块的列表。我希望在一页中绘制每个内部图表列表。我使用 ggsave 是因为我没有找到可以控制绘图宽度和高度的解决方案。

这是错误:

错误:无法添加theme到主题对象。

绘图代码:

任何帮助将不胜感激!谢谢!

0 投票
2 回答
79 浏览

r - 使用 ggsave (ggplot2) 以不同的文件格式保存 ggplot 两次

有没有办法用一个 ggsave 命令将 ggplot 两次保存为不同的文件格式?例如 plot.pdf 和 plot.png

0 投票
0 回答
48 浏览

r - 导出为 pdf 时,ggsave 会更改图形

我使用ggplot. 当我使用基本ggsave命令保存它时:

图形刻面和标签的边距发生变化。

它在 Rstudio 绘图预览中的样子:

工作室预览:
工作室预览

ggsave通过更改边距厚度创建的 PDF :

ggsave 导出:
ggsave 导出

使用以下命令:

或使用 Rstudio pdf 导出功能或cowplot

save_plot()更糟糕的是,现在标签字体大小也发生了变化:

pdf() 导出:
pdf() 导出

有没有更可靠的工具来创建 PDF?我希望它看起来与 Rstudio 中的一样。很抱歉没有发布整个代码,因为源数据框非常复杂,同时我将尝试创建一个可重现的示例。