[英]Increase distance between points in a categorical X axis
我將geom_point
與position_dodge
結合使用以繪制點並將它們在水平軸上散布一些。 問題在於一個基准的點太接近另一個基准的點(即atax和bicg)。
當軸為分類軸時,如何增加X軸刻度線之間的距離? 或者,如何防止不同基准的點彼此接觸。
下面是我用來在1上產生數字的代碼
ggplot(data = df, aes(x = Benchmark, y = time, shape = type)) +
theme_light() +
theme(axis.text.x = element_text(angle = 45, hjust = 1)) +
scale_shape_manual(values = c(0, 1, 2, 3, 4)) +
geom_point(position = position_dodge(width = 1), color = 'gray60', size = 2)
您可以使用scale_x_discrete
的expand
參數來執行此操作,在scale_x_discrete
中添加一條類似於scale_x_discrete(expand=c(0.2, 0.2))
並使用這些值。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.