将图像插入到 ggplot2 [英] Inserting an image to ggplot2
本文介绍了将图像插入到 ggplot2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以在 ggplot2
绘图上的 geom_line()
下方插入光栅图像或 pdf 图像?
Is it possible to insert a raster image or a pdf image underneath a geom_line()
on a ggplot2
plot?
我希望能够快速在先前计算的绘图上绘制数据,该绘图需要很长时间才能生成,因为它使用了大量数据.
I wanted to be quickly able to plot data over a previously calculated plot that takes a long time to generate as it uses a large amount of data.
我通读了这个示例一>.但是,由于它已经一年多了,我认为现在可能会有不同的方法来做到这一点.
I read through this example. However, as it is over one year old I thought there might be a different way of doing this now.
推荐答案
try ?annotation_custom
in ggplot2
示例,
library(png)
library(grid)
img <- readPNG(system.file("img", "Rlogo.png", package="png"))
g <- rasterGrob(img, interpolate=TRUE)
qplot(1:10, 1:10, geom="blank") +
annotation_custom(g, xmin=-Inf, xmax=Inf, ymin=-Inf, ymax=Inf) +
geom_point()
这篇关于将图像插入到 ggplot2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文