我如何合并两个在 ggplot 2 中显示比例比例的图例。我有一个数据框df
。我得到了下面的情节 1 和下面的代码。现在我如何合并这两个图例以显示成比例的大小和类。我想制作如下图 2 所示的图例。
dput(df)
structure(list(x = c(58.54, 58.07, 57.9, 56.71, 56.74, 56.11,
55.22, 55.13, 56.35, 55.43, 55.46, 55.43, 53.93, 54.12, 54.62,
54.65, 54.81, 54.61, 54.63, 54.48), y = c(-133.7, -130.82, -131.15,
-132.13, -131.67, -129.48, -129.14, -129.35, -130.69, -127.71,
-127.85, -126.7, -127.45, -127.42, -126.9, -127.12, -127.2, -127.5,
-128.43, -128.33), value = c(387.619784071665, 37.1752327050295,
409.872664195269, 1579.07184277674, 459.494444037465, 15.605721248393,
779.623269533058, 1.01892098254864, 104.561783471334, 45.1993322681666,
0.421293689514635, 50.6940007133332, 28.9504788576929, 75.1053594034691,
134.557578318905, 1.77584069574919, 0.265461776554673, 14.3060733821441,
903.028086907651, 105.510779979692), value_interval = c("100-500",
"1-100", "100-500", ">1500", "100-500", "1-100", "500-1000",
"1-100", "100-500", "1-100", "<1", "1-100", "1-100", "1-100",
"100-500", "1-100", "<1", "1-100", "500-1000", "100-500")), .Names = c("x",
"y", "value", "value_interval"), row.names = c(NA, 20L), class = "data.frame")
获取比例图的代码
plott<-ggplot(df)+
geom_point(aes(x = x, y = y,color=value_interval, size =value),
alpha = 1, shape=16)+
scale_size_continuous(name="Proportion",range=c(3,10))+
scale_color_manual(name= " ",limits=c("<1","1-100","100-500","500-1000","1000-1500",">1500"),
values=c("Red","Blue","darkgoldenrod2","darkgreen","firebrick2","darkorange","deepskyblue"))
plott