【发布时间】:2022-01-18 10:56:11
【问题描述】:
早上好,我的ggplot 图表有点问题。
由于某种原因,我现在看不到 y 轴刻度和数字。也许,我在这里遗漏了一些非常明显的东西,或者它在我的设置中。
牙齿生长数据集并不真正适合图表,但您仍然可以看到问题(通常包含facet_wrap,但不适用于此数据集)。
library(tidyverse)
library(ggbeeswarm)
library(gghalves)
library(tidyr)
library(ggplot2)
library(ggpubr)
theme_set(theme_bw(16))
data <- ToothGrowth
a<- ggplot(data, aes(x=supp, y=len)) +
geom_half_boxplot(
data = data %>% filter(supp=="OJ"),
aes(x = supp, y = len, fill=supp), outlier.color = NA) +
scale_fill_manual(values=c("#F2F2F2", "#999999"))+
geom_half_boxplot(
data = data %>% filter(supp=="VC"),
aes(x = supp, y = len, fill=supp), side = "r", outlier.color = NA) +
geom_line(aes(group=supp, colour = supp), position = position_dodge(0.2), alpha = 0.3) +
geom_point(aes(group=supp, colour = supp),size=1,shape=21, position = position_dodge(0.2)) +
scale_color_manual(values=c("chartreuse3", "yellow2",
"firebrick3"))+
# facet_wrap(~ supp)+
# theme(
# strip.background = element_blank(),
# strip.text.x = element_blank())+
theme(plot.margin=unit(c(0,0,0,0),"cm"))+
scale_y_discrete(name ="Name")+
theme(text = element_text(size=11))+
theme(legend.position = "none")
a
如果有人能看到问题就好了;我现在要瞎了。非常感谢!!
【问题讨论】:
-
因为映射到 y 上的变量看起来像一个数字:尝试使用
scale_y_continuous(name ="Name")而不是scale_y_discrete。
标签: r ggplot2 boxplot axis-labels