以下面的1364656 000280169fc78d704a2d4569bfb6f42ea4a1d5ae 8203 2015-11-17
3483047 00061dc0bc2452304107ddc75e7ee2908c729905 28618 2017-08-17
示例
data.frame
这是我的原始数据的简短示例。
在我的data.frame中,我有180个名称,这些名称与library(ggplot2)
names <- c("AA", "BB", "CC", "DD", "EE", "FF")
coding <- c("yellow", "blue", "red", "yellow", "blue", "blue")
variable <- c("A1", "A2", "A3", "A4", "A5", "A6")
values <- c(1,6,12,4,5,7)
data_test <- data.frame(names,coding,variable,values)
ggplot(data_test, aes(variable, reorder(names, -values), size = values, colour = coding)) +
geom_point()
的8个级别相关联。
这是我的位置,但是我需要相同的颜色(代表variable
级别)彼此相邻
答案 0 :(得分:1)
使用scale_manual_colour
在编码列中为颜色名称赋值:
names <- c("AA", "BB", "CC", "DD", "EE", "FF")
coding <- c("yellow", "blue", "red", "yellow", "blue", "blue")
variable <- c("A1", "A2", "A3", "A4", "A5", "A6")
values <- c(1,6,12,4,5,7)
data_test <- data.frame(names,coding,variable,values)
ggplot(data_test,
aes(variable, reorder(names, -values),size = values,color=coding)) +
geom_point()+
scale_colour_manual(values = c('yellow'='yellow','blue'='blue','red'='red'))