我使用ggplot制作了以下图表:Likert-style bar chart。 y轴文本(带有国家名称)突出显示在图表标题的左侧,而我希望它看起来更接近条形。我试图在主题中使用vjust参数(axis.text.y = element_text(vjust = 1.5)),但它的参考点是文本的中间部分。因此标签看起来彼此错误。我希望他们只需向右移动几个点并保持一致。
我的代码:
p <- dane_1long %>%
ggplot() +
geom_segment(aes(x = Kraj, y = start, xend = Kraj, yend = start + value,
colour = variable), size = 6) +
geom_text(aes(label = scales::percent(round((value), digits = 2)),
x = Kraj, y = (start + value)-value/2),
size = 3, family = "ING Me") +
coord_flip() +
theme_classic() +
scale_color_manual("", labels = c("Zdecydowanie\nsię nie zgadzam", "Nie
zgadzam się", "Ani się zgadzam,\nani się nie zgadzam",
"Zgadzam się", "Zdecydowanie\nsię zgadzam"),
values = ING_Likert_palette, guide = "legend") +
scale_y_continuous(breaks = seq(- 75, 75, 25), limits=c(- 0.75, 0.75)) +
labs(title = tresc_pytania,
subtitle = "Próba: 14 806 osób",
caption = "Źródło: Barometr finansowy ING",
y= " Percent",x= "") +
theme(plot.title = element_text(face = "bold"),
plot.subtitle = element_text(size = 7),
plot.caption = element_text(size = 7, face = "italic"),
legend.position = "top",
legend.text = element_text(family = "ING Me",
size = 8,
color = grey(.3)),
axis.title.x = element_blank(),
axis.title.y = element_blank(),
axis.line = element_blank(),
axis.ticks = element_blank(),
text = element_text(family = "ING Me",
size = 14,
color = grey(.3))); p
答案 0 :(得分:0)
这个巨大的空间是因为对称的情节,数据更多地位于积极的网站上。通过更改限制来稍微更改y轴刻度。
scale_y_continuous(breaks = seq(- 50, 75, 25), limits=c(- 0.51, 0.76))