我想使用ggplot2在医院平面图的PNG上映射职业健康安全事件。我试过将这张非地理地图作为ggimage读取。

到目前为止,我已经用我拥有的数据集(14462)观察值尝试了以下方法。
示例数据集
toy <- data.frame(patient_ID = c(1001,1001,1002,1003,1004),
SEX = c("M","M","F","F","F"),
phenotype = c("Psychiatric","Psychiatric", "Cardio",
"Cancer","Psychiatric"),
x = c(0.5737, 0.5737, 0.6968, 0.4704, 0.6838),
y= c(0.3484, 0.3484, 0.62, 0.5216, 0.2486))我试着将文件作为栅格读取,然后使用ggmap,但难度不是很大。
library(ggmap)
library(png)
library(ggplot2)
library(data.table)
toy <- fread("toy.csv")
# read in image
r <- readPNG("ICU-crop.png")
#use ggimage to convert to plot and add gender
ggimage(r, scale_axes = TRUE) +
geom_point(aes(x = x, y = y, colour = SEX), data = toy,
size = I(1), fill = NA)我真的很想使用ggplot,但需要图例。我不确定还有什么方法可以用来在PNG上进行ggplot。
https://stackoverflow.com/questions/38290832
复制相似问题