将图像插入ggplot2 [英] Inserting an image to ggplot2

查看:86
本文介绍了将图像插入ggplot2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在 ggplot2 图上的 geom_line()下插入光栅图像或pdf图像?



我希望能够快速绘制出以前计算出来的图表,因为它使用了大量数据,因此需要很长时间才能生成数据。



我通过阅读示例的。但是,因为它已经超过一年了,我认为现在可能有不同的方式。

ggplot2



示例,

code>?annotation_custom b
$ b

  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()


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

example,

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屋!

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