我有以下数据(类:data.frame)
tval V2
0.15992376 -0.8343450463
0.10649188 -0.1661683709
0.50782252 -0.3090289856
0.40839714 1.3591006969
0.87263438 -0.1140296582
-0.67082150 0.5563068416
1.04550767 -0.0835169157
1.55295583 0.9997731998
1.91169754 0.3246076173
-0.25082386 0.0638465365
-0.56745556 0.9553410876
0.19166267 -0.4120324771
2.29615058 -1.9694192327
1.40662861 -1.0248516180
1.91100408 -0.4167153416
-0.06249463 -0.1230196521
-2.38623303 -0.2223423823
-1.84545755 -0.1886771462
2.25594931 -2.6459779048
0.11613099 0.5586652937
和以下代码:
sizez< -14
library(tidyverse)
data1 %>%
gather(key, value) %>%
ggplot(aes(value, color=key)) +
stat_ecdf(size=0.8) + xlim(-4.5,4.5) +
labs(x = "t(alpha)", y = "Probability", color="Legend") +
scale_colour_discrete(labels = c("Actual","Simulation")) +
theme(legend.title=element_text(size=sizez+1),
legend.text=element_text(size=sizez),
axis.text=element_text(size=sizez-1),
axis.title=element_text(size=sizez))
产生这个情节:
我的问题是如何在不更改legend.key.height的情况下更改图例之间的垂直间距?它是两个传说(灰色框)之间的白色间距我想要更大。
我见过这个解决方案:
sizez<-14
library(tidyverse)
data1 %>%
gather(key, value) %>%
ggplot(aes(value, color=key)) +
stat_ecdf(size=0.8) + xlim(-4.5,4.5) +
labs(x = "t(alpha)", y = "Probability", color="Legend") +
scale_colour_discrete(labels = c("Actual","Simulation")) +
theme(legend.title=element_text(size=sizez+1),
legend.text=element_text(size=sizez),
axis.text=element_text(size=sizez-1), axis.title=element_text(size=sizez)),
legend.key = element_rect(fill = "white"),
legend.key.height = unit(2, "cm"))
产生:
但是我想保留关键线周围的灰色框,所以它对我不起作用。谁有解决方案?
提前谢谢!