从同一位置开始的不同长度的 x 轴刻度标记标签

x axis tick mark labels of different length starting at same position

我对 ggplot2 中的轴标签和刻度线有疑问。 x轴显示不同的长度类,y轴显示个体的数量。如何使 x 轴长度 类 的所有刻度标签都从同一位置(顶部)开始?目前较短的标签例如(51-60) 居中,而较长的 (121-130) 写在较高的位置。我如何排列它们,使它们的起始高度相同 level/position?我也不知道为什么它不显示我的 x 和 y 轴标题。

感谢您的帮助!

ggplot(data=ALL, aes(x=Langenklasse_Zahl, y=Anz.10.ha)) + 
  geom_bar(stat="identity")+
  scale_x_continuous(name="Längenklasse")+
  scale_y_continuous(name="Anzahl Bachforellen")+
  scale_y_continuous(limits=c(0, 84))+
  scale_x_discrete(breaks=c("1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31","32"), 
  labels=c("31-40","41-50","51-60","61-70","71-80","81-90","91-100","101-110","111-120","121-130","131-140", "141-150", "151-160", "161-170", "171-180", "181-190", "191-200", "201-210", "211-220", "221-230", "231-240", "241-250", "251-260", "261-270", "271-280", "281-290", "291-300", "301-310", "311-320", "321-330","331-340", ">340"))+
 theme(axis.title.y = element_text(vjust=1.3, size=15),
    axis.text.y  = element_text(vjust=0.5, size=15),
    axis.title.x = element_text(vjust=-.5, size=15),
    axis.text.x  = element_text(angle=90,vjust=0.5, size=15))+
 ggtitle("Längendiagramm der kanalisierten Strecke im Mai 2014") + 
 theme(plot.title = element_text(lineheight=3, size=20, face="bold"))

数据:

Langenklasse_Zahl Langenklasse Anz 10 公顷
1 31-40 0
2 41-50 0
3 51-60 0
4 61-70 0
5 71-80 0
6 81-90 0
7 91-100 0
8 101-110 3
9 111-120 12
10 121-130 12
11 131-140 15
12 141-150 9
13 151-160 9
14 161-170 6
15 171-180 3
16 181-190 0
17 191-200 3
18 201-210 3
19 211-220 0
20 221-230 0
21 231-240 0
22 241-250 0
23 251-260 3
24 261-270 3
25 271-280 9
26 281-290 0
27 291-300 3
28 301-310 3
29 311-320 0
30 321-330 3
31 331-340 0
32 >340 6

要使 x 轴标签位于相同的起始位置,请将 hjust=1hjust=0 添加到 theme() 元素 axis.text.x=

 + theme(axis.text.x  = element_text(angle=90,vjust=0.5, size=15,hjust=1))

您的坐标轴标题未显示,因为您必须 scale_x_continuous()scale_y_continuous() 调用。将轴的标题移动到您提供中断、标签和限制的相同 scale_... 调用,例如,

 + scale_y_continuous(name="Anzahl Bachforellen",limits=c(0, 84))+