40

vjustは回避策として使用し、試行錯誤して許容できる距離を詳しく説明しました。ただし、これには非常に時間がかかる場合があり、フォント サイズと軸のスケールによって変化します。

自動の例でテキストを揃えるより良い方法はありますか?

library(ggplot2)

ggplot(data=mtcars, aes(x=hp, y=mpg))+
geom_point()+
theme_bw() +
  geom_vline(xintercept=200, colour="grey") +
  geom_text(aes(x=200, label="the strong cars", y=20), colour="blue", angle=90, vjust = 1.2, text=element_text(size=11))+
  geom_text(aes(x=200, label="the weak cars", y=20), colour="red", angle=90, vjust = -1, text=element_text(size=11))

ggsave(filename="geomline.png", width=5.5, height=2*3, dpi=300)

ここに画像の説明を入力

4

1 に答える 1