【发布时间】:2020-08-20 02:34:14
【问题描述】:
我正在尝试使用“axis.line.y.right”来操纵右 Y 轴,但轴没有改变。我使用了以下主题,但只有左侧 Y 轴和底部 X 轴根据所需的参数更改了它们的颜色和大小。我不知道我做错了什么。非常感谢。
C57.sum
Genotype Group Strain my_mean CI.plus CI.minus my_n
WT C57BL C57BL/6J 0.403 0.482 0.319 12
my.theme = list(theme(axis.line.y.left = element_line(size = 3, color = "red"),
axis.line.y.right = element_line(size = 3, color = "red"),
axis.line.x.top = element_line(size = 3, color = "red"),
axis.line.x.bottom = element_line(size = 3, color = "red")),
ylim(0,5))
Plot <- ggplot() +
geom_bar(data = C57.sum,
aes(y = my_mean, x = Strain, fill=Group),
color="black", stat="identity", width = 0.6, show.legend = FALSE,
position = position_dodge2(preserve = "single")) +
geom_linerange(data = C57.sum,
aes(x = Strain, ymin = CI.minus, ymax = CI.plus),
color = "black", size = 0.42,
position = position_dodge2(preserve = "single", width = 0.6)) +
geom_text(data = C57.sum,
aes(y = 0, x = Strain, group = Group, label=paste0("n = ",my_n), vjust=1.4),
size = 2.8, fontface = "italic", position = position_dodge(0.6)) +
coord_fixed(ratio=4/5) +
my_theme.2
Plot
【问题讨论】:
-
如果没有看到生成绘图的其余代码,您的问题是不可重现的,尽管我想
ylim(0, 5)可能与它有关(它可能覆盖了scale_y_**的早期行其中包括右 y 轴的规格)。 -
感谢您的评论...我已添加其余代码
-
我们没有您的数据。可以使用 R 中可用的通用数据集(例如 mtcars)来表示此问题吗?