#r #ggplot2 #plot #legend
Вопрос:
У меня есть этот вулканический участок
Я хочу удалить logp
строку-в легенде. Поэтому я попытался
guides(colour = guide_legend(override.aes = list(size = 10)),
size = guide_legend(override.aes = list(size = 10)))
и ... size = guide_legend(override.aes = NA))
и ... size = guide_legend(override.aes = "none"))
Однако это не решило проблему. Как я могу удалить эту конкретную часть?
Мой сценарий
ggplot(BT_Ctrl, aes(x = diff, y = logp))
geom_point(data = filter(BT_Ctrl,
(logp > 0 amp; logp < (-log(0.1))) | (logp > (-log(0.1)) amp; diff > (-1) amp; diff < 0)
),
alpha = 0.35, size = 3, color = "grey50", fill = "grey60", shape=21, stroke = 1)
geom_point(data = filter(BT_Ctrl,
(logp > (-log(0.1)) amp; diff < (-1)) | (logp > (-log(0.1)) amp; diff > 0)) %>%
mutate(group = ifelse(diff > 0, "Tumor", "Ctrl")),
aes(color = group, fill = group, size = logp), shape = 21, stroke = 1)
scale_size(range = c(4,8))
scale_fill_manual(values = alpha(c("#D1B551", "#678F53"), 0.2),
name = "",
labels = c("Low abundant",
"High abundant"))
scale_colour_manual(values = c("#D1B551", "#678F53"),
name = "",
labels = c("Low abundant",
"High abundant"))
scale_alpha_manual(values=c(0.01, 0.2, .1), guide = "none")
scale_x_continuous(breaks = seq(-3, 4, 1),
name = "**Difference on log<sub>2</sub>-scale**")
scale_y_continuous(breaks = seq(0, 8, 1),
name = "**-log**(*P*-value)")
coord_cartesian(ylim = c(0, 8),
xlim = c(-3.5, 4))
guides(colour = guide_legend(override.aes = list(size = 10)),
size = guide_legend(override.aes = list(size = 10)))
theme(axis.line = element_line(colour = "black",
size = .6),
panel.grid.major = element_line(colour = "gray95"),
panel.grid.minor = element_line(colour = "gray95"),
panel.border = element_blank(),
panel.background = element_blank(),
axis.text.x = element_text(color = "grey20", size = 16),
axis.title.x = ggtext::element_markdown(color = "grey20", size = 22,
margin = ggplot2::margin(t = 10)),
axis.text.y = element_text(color = "grey20", size = 16),
axis.title.y = ggtext::element_markdown(color = "grey20", size = 25,
margin = ggplot2::margin(r = 8)),
legend.key = element_rect(fill = "white"),
plot.title = ggtext::element_markdown(color = "grey20",
size = 20, hjust = 0),
plot.subtitle = element_text(hjust = 0.5),
legend.text = ggtext::element_markdown(size = 30),
legend.title = element_text(size = 20, hjust = 0.5),
legend.position = "bottom")
С образцом данных:
BT_Ctrl <- structure(list(logp = c(1.892315213, 1.741122091, 0.561899231,
0.036655082, 0.980036153, 0.17522181, 0.091824698, 0.108312434,
1.271318168, 1.076396099, 0.810250042, 0.260831199, 0.215034285,
0.757343375, 0.482811756, 0.744494045, 0.289560753, 0.88281578,
0.413021101, 0.277454405, 2.05682268, 0.004352447, 0.830231027,
0.733181724, 0.355808451, 0.494777499, 0.272399182, 0.734279471,
0.904390655, 0.093881396, 2.263531464, 2.183779415, 0.002000274,
0.288928922, 0.108312434, 1.631564514, 1.863799992, 0.038540997,
0.351032435, 0.389484032, 0.27672349, 0.868411145, 0.146638783,
0.222894374, 0.785553332, 0.503424902, 0.007184975, 0.143643702,
0.706542278, 0.399474359, 1.398223879, 0.277454405, 0.070263867,
0.196525572, 0.714977904, 0.359791631, 1.53290454, 1.319926396,
2.539142436, 1.481669911, 0.227928051, 0.105656067, 0.571121048,
0.098156733, 0.063262205, 0.73837595, 0.064271242, 0.601613347,
0.122076363, 1.691585028, 0.537070368, 0.001707348, 0.937587345,
1.902615044, 0.26791295, 0.939251545, 0.027628346, 0.333192597,
2.454661239, 0.430268931, 0.517377715, 1.795537119, 0.899703873,
0.171224188, 0.407711105, 0.101449286, 1.989191981, 0.250549532,
0.276978823, 3.759602247, 0.253764539, 0.031279861, 0.130796447,
0.269354234, 0.598702594, 2.600656132, 0.105037153, 1.125756856,
0.265984845, 0.053120566), diff = c(1.20234619, -1.70295885,
0.65457164, 0.06714772, -0.80261127, -0.26141931, 0.13191337,
-0.17023798, -1.00645538, -1.12120783, 0.78954709, 0.39286592,
0.3128407, 0.94129525, -0.65648018, -0.55756632, -0.30731923,
-0.89000336, 0.59985586, 0.43502626, -1.55898508, -0.00761563,
-0.70479107, 0.71041436, -0.50044067, -0.62982497, -0.44573634,
-0.75347176, -0.8137711, -0.16123801, 1.77236427, -1.87675892,
-0.00340981, -0.29575161, -0.17023798, 1.307873, -1.72798215,
0.06637002, -0.46851144, -0.55572908, -0.37359508, 0.72585016,
-0.17725634, 0.34547909, 0.61925212, -0.53240673, 0.01361836,
-0.23351898, 0.93210313, -0.34450825, 1.09251706, 0.43502626,
-0.09880463, -0.25131522, -0.73972942, -0.48159189, -1.46794924,
1.07828034, -1.6589846, -0.99656108, -0.31415414, -0.13807622,
0.51838817, 0.19589304, -0.0937803, 0.75802953, -0.09147411,
0.67878846, 0.19139068, 1.52384739, 0.51390223, -0.00206126,
-1.04672091, 1.55164341, -0.4140512, 0.83026286, 0.04245698,
-0.41767947, 1.78143388, -0.48238462, -0.48817196, -1.57535168,
-0.99213411, -0.23038557, -0.46668723, -0.17994928, -1.36902852,
0.32038784, 0.34062497, 1.93588366, 0.26186093, 0.04413918, -0.20751399,
-0.33032721, -0.52244521, 1.59749734, 0.14740854, -0.85269934,
0.33985544, 0.0960661)), row.names = c(NA, -100L), class = c("tbl_df",
"tbl", "data.frame"))
Ответ №1:
Просто
guides(colour = guide_legend(override.aes = list(size = 10)), size = "none")
сделал это