早上好,我的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

如果有人能看到問題就太好了;我現在快瞎了。非常感謝!!
uj5u.com熱心網友回復:
你的 y 軸不應該是連續的嗎?
scale_y_continuous(name ="Name")
然后您可以根據需要添加限制和刻度位置:
scale_y_continuous(name="Name",limits=c(min,max), breaks=c(a,b,c,d))
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/384681.html
