我对R比较陌生,我正试图制作一个泡泡情节,令人兴奋! 其中大部分是有效的,除了我似乎无法做两件事:
变量(datasheet):
ycode = 4
类别我给了数字(1-3;7-9;13-15;19-21)
以允许y轴上有一些间距
我对此变量应用了一些抖动以将气泡拉出彼此
staging = 15
大脑区域的数字按我希望它们出现在X轴上的顺序排列
Group = 4 groups
这是代码:
bub$jitTau <- jitter(as.numeric(factor(bub$ycode)))
gp <- ggplot(data = bub, aes(x = bub$staging, y = bub$ycode,
size = bub$sample_size, color = bub$Group)) +
geom_point(data = bub, aes(x = bub$conc_area, y = bub$jitTau,
size = bub$sample_size, color = bub$Group) +
theme_classic(base_size = 35))
gp <- gp + scale_size(range = c(5, 35), name = "Sample size") +
scale_y_discrete(breaks = c(3, 8, 13, 19),
labels = c("p-tau/abeta", "t-tau/abeta", "p-tau", "t-tau")) +
labs(x = "Brain Regions", y = "CSF measures") +
scale_x_discrete(breaks = 1:15, labels = c("EC", "Hipp", "PHG", "Amyg", "ITG",
"Fusiform", "MTG", "STG", "Lat parietal",
"PCC", "Precuneus", "Frontal", "Striatum",
"Thalamus", "Occipital"),
limits = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15)) +
geom_hline(yintercept = c(5, 11, 17, 22), colour = "grey") +
scale_colour_manual(name = "Group", breaks = c("All", "HC", "MCI", "AD"),
values = c("#333333", "#006600", "Blue", "Red")) +
guides(colour = guide_legend(override.aes = list(size = 18))) +
theme(axis.title.x = element_text(size = 30),
axis.title.y = element_text(size = 20),
axis.text = element_text(size = 16)) +
theme_classic(base_size = 35)
gp
我用theme(axis.text.x = element_text(size = 18))
尝试了几件事,但R没有回应。
我还试图改变图例的位置(legend.position
),但没有发生任何变化。
有什么建议吗?
答案 0 :(得分:2)
如果没有数据,则无法重现您的确切问题,但看起来您正处于正确的轨道上。您的设置应如下所示:
ggplot(iris, aes(x = Petal.Length, y = Petal.Width, colour = Species)) +
geom_point() +
theme_classic() +
theme(text = element_text(size = 15, family = 'Garamond'),
legend.position = 'bottom',
legend.direction = 'horizontal')
我认为,在您特定theme_classic
之后,您需要放弃theme
。如果您有相互冲突的值,那么最后添加的内容就是绘制的内容。例如,如果我使用上面的确切代码,但将theme_classic
移到最后,我会得到