I’m making two volcano plots using ggplot and the parameters in both of them are the same except for the legend. However, the font size of the legends is different between the two plots. How can I fix this?
Also, how can I get the blue labels to be on one side and the pink ones on the other side? And is there a way that the lines connecting the dots to the labels be more consistent?
ggplot(data = resLFC, aes(x = log2FoldChange, y = -log10(padj), col = diffs, label = delabel)) +
coord_cartesian(xlim = c(-30,30), ylim = c(-10,80)) +
geom_vline(xintercept = c(-1, 1), col = "blue", linetype = "dashed") +
geom_hline(yintercept = 4, col = "red", linetype = "dashed") +
geom_point() +
scale_color_manual(values = c("dodgerblue1", "gray", "deeppink1"),
labels = c("Downregulated", "Not significant", "Upregulated")) +
labs(color = "test 2 vs test 1
in testtt testttt",
x = expression("log"[2]*"FC"), y = expression("-log"[10]*"p-value")) +
geom_label_repel(nudge_x = c(-30,30), nudge_y = c(-10,20),force = 100,
max.iter = 200000, max.segment.length = 0.005, max.overlaps = 10000) +
theme(legend.position = c(0.15, 0.80), legend.key.height = unit(0.3, "cm"),
legend.key.width = unit(1, "cm"), axis.text.x = element_text(size = 20),
axis.text.y = element_text(size = 20), axis.title.x = element_text(size = 20),
axis.title.y = element_text(size = 20), legend.text = element_text(size = 8))
ggplot(data = resLFC, aes(x = log2FoldChange, y = -log10(padj), col = diffs, label = delabel)) +
coord_cartesian(xlim = c(-30,30), ylim = c(-10,80)) +
geom_vline(xintercept = c(-1, 1), col = "blue", linetype = "dashed") +
geom_hline(yintercept = 4, col = "red", linetype = "dashed") +
geom_point() +
scale_color_manual(values = c("dodgerblue1", "gray", "deeppink1"),
labels = c("Downregulated", "Not significant", "Upregulated")) +
labs(color = "test 2 vs test 1
in test test",
x = expression("log"[2]*"FC"), y = expression("-log"[10]*"p-value")) +
geom_label_repel(nudge_x = c(-30,30), nudge_y = c(-10,20),force = 100,
max.iter = 200000, max.segment.length = 0.005, max.overlaps = 10000) +
theme(legend.position = c(0.15, 0.80), legend.key.height = unit(0.3, "cm"),
legend.key.width = unit(1, "cm"), axis.text.x = element_text(size = 20),
axis.text.y = element_text(size = 20), axis.title.x = element_text(size = 20),
axis.title.y = element_text(size = 20), legend.text = element_text(size = 8))
Recognized by R Language Collective
6