長い名前を持つカテゴリ変数 (boxplot など) を含むグラフをプロットする場合、theme
ggplot2 のコマンドを使用して名前をシフトする必要があります。その後、軸の目盛りとテキストの間の距離も設定できますが、この距離は両方の軸に反映されます。 1 つの軸でのみ必要な時間が必要な場合。サンプルコードの下:
df<-data.frame(X=rnorm(50,0,10),Y=c(rep("Some Text",25),rep("Some Larger Text That Takes Space",25)))
#classical boxplots
ggplot(df,aes(x=Y,y=X))+geom_boxplot()+theme(axis.text=element_text(size=20),axis.text.x=element_text(angle=45))
#the x axis labels need to be shifted downwards
ggplot(df,aes(x=Y,y=X))+geom_boxplot()+theme(axis.text=element_text(size=20),axis.text.x=element_text(angle=45),axis.ticks.margin=unit(4,"cm"))
#now they are shifted but there is unnecessary space on the y-axis
axis.ticks.margin
1 つの軸のみに作用するように設定するにはどうすればよいでしょうか?