我指的是答案这个问题 ,并有额外的问题。
我有修改的代码如下:
library(ggplot2)
ids <- letters[1:2]
# IDs and values to use for fill colour
values <- data.frame(
id = ids,
value = c(4,5)
)
# Polygon position
positions <- data.frame(
id = c(rep(ids, each = 10),rep("b",5)),
# shape hole shape hole
x = c(1,4,4,1,1, 2,2,3,3,2, 5,10,10,5,5, 6,6,7,7,6, 8,8,9,9,8),
y = c(1,1,4,4,1, 2,3,3,2,2, 5,5,10,10,5, 6,7,7,6,6, 8,9,9,8,8)
)
# Merge positions and values
datapoly <- merge(values, positions, by=c("id"))
chart <- ggplot(datapoly, aes(x=x, y=y)) +
geom_polygon(aes(group=id, fill=factor(value)),colour="grey") +
scale_fill_discrete("Key")
并给出了下面的输出:
有经过两个彩色框一条线,我不很喜欢它,我怎么能删除吗? 谢谢。