r - 如何以 png 作为背景进行绘图?

标签 r data-visualization large-data

我制作了一个 300 万点的绘图并将其保存为 PNG。花了几个小时,我想避免重新绘制所有点。

enter image description here

如何生成以此 PNG 作为背景的新绘图?

最佳答案

试试这个:

library(png)

#Replace the directory and file information with your info
ima <- readPNG("C:\\Documents and Settings\\Bill\\Data\\R\\Data\\Images\\sun.png")

#Set up the plot area
plot(1:2, type='n', main="Plotting Over an Image", xlab="x", ylab="y")

#Get the plot information so the image will fill the plot box, and draw it
lim <- par()
rasterImage(ima, lim$usr[1], lim$usr[3], lim$usr[2], lim$usr[4])
grid()
lines(c(1, 1.2, 1.4, 1.6, 1.8, 2.0), c(1, 1.3, 1.7, 1.6, 1.7, 1.0), type="b", lwd=5, col="white")

下面是剧情

enter image description here

关于r - 如何以 png 作为背景进行绘图?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12918367/

相关文章:

r - 当我设置 x 和 y 限制时,ggplot 会删除所有数据

python - 如何更改 Seaborn 的 relplot(seaborn.relplot 不是 regplot)上的散点大小? Seaborn 0.9.0

r - 在非常大的数据集中使用多个条件进行子集化

javascript - 在 R Shiny 的数据表中添加工具提示

r - 使用 group_by 和 summarize 时出现重复行

r - 设置行名或行名的最佳方法?

r - 使 Plot 看起来像 R 中的 Bloomberg Plot

data-visualization - 使用 Mapbox GL JS 切换图层

android - 将大量数据加载到数据库 - Android

c - 如何在C中对一个非常大的数组进行排序