R 如何调整其中一个杆';直方图中的标签是什么?

R 如何调整其中一个杆';直方图中的标签是什么?,r,ggplot2,R,Ggplot2,我的密码在这里 Yr = c("2016","2017","2016","2017","2016","2017") Type = c("A","A","B","B","C","C") Value = c(73,183,160,476,11,73) Percentage = c(29.92,25.00,65.57,65.03,4.51,9.97) p1Data <- data.frame(Yr,Type,Value,Percentage) library(ggplot2) p1 <

我的密码在这里

Yr = c("2016","2017","2016","2017","2016","2017")
Type = c("A","A","B","B","C","C")
Value = c(73,183,160,476,11,73)
Percentage = c(29.92,25.00,65.57,65.03,4.51,9.97)
p1Data <- data.frame(Yr,Type,Value,Percentage)

library(ggplot2)

p1 <- ggplot(p1Data, aes(Type, Value, fill = Yr)) +
  geom_bar(stat = "identity", position = position_dodge(width = 0.9)) +
  theme(axis.title.x = element_blank(), plot.title = element_text(hjust = 0)) +
  geom_text(aes(label = paste(Value, paste(Percentage, "%"), sep = "\n"), y = Value), size = 4, vjust = 1.5, position = position_dodge(width = 0.9)) +
  ggtitle("2016 V.S. 2017")  +
  labs(fill = "Catagory")
Yr=c(“2016”、“2017”、“2016”、“2017”、“2016”、“2017”)
类型=c(“A”、“A”、“B”、“B”、“c”、“c”)
值=c(73183160476,11,73)
百分比=c(29.92,25.00,65.57,65.03,4.51,9.97)

p1Data您可以将
geom\u文本中的
vjust=1.5
更改为
vjust=“inwards”

ggplot(p1Data, aes(Type, Value, fill = Yr)) +
  geom_bar(stat = "identity", position = position_dodge(width = 0.9)) +
  theme(axis.title.x = element_blank(), plot.title = element_text(hjust = 0)) +
  geom_text(aes(label = paste(Value, paste(Percentage, "%"), sep = "\n"), 
                y = Value), 
            size = 4, 
            vjust = "inward", 
            position = position_dodge(width = 0.9)) +
  ggtitle("2016 V.S. 2017")  +
  labs(fill = "Catagory")

您实际希望标签放在哪里?你只想移动被切断的那一个,还是全部?…从技术上讲,这不是直方图,只是一个barplot@alistaire想把这个标签放在条顶上吗~哈哈哈~我只是R的初学者谢谢你的评论,让我知道这只是一个条形图:谢谢你的帮助!