簡體   English   中英

Geom_line 基於y 軸連接geom 點?

[英]Geom_line connects geom points based on y-axis?

我試圖在 x 軸上連接基於 position 的 ggplot 的點,但是使用基本設置我的 plot 連接基於它們的 y 軸線的點: 基礎圖表

當我將group=1添加到geom_line()時,它通過 y 軸連接點:

幾何線(組=1)

這是代碼的副本和小型 SRS。 我只想按照它們在 x 軸上出現的順序連接我的點,在此先感謝。

df
#      x z   y
#  1:  1 A A27
#  2:  2 C C11
#  3:  3 A A19
#  4:  4 A A27
#  5:  5 B B25
#  6:  6 A A27
#  7:  7 B B25
#  8:  8 B B26
#  9:  9 A A29
# 10: 10 A A38
ggplot(df, aes(x, y, color=z))+geom_point(size=3) +geom_line(size =1, group=1)+
  scale_y_discrete(limits=rev)

您正在尋找這樣的解決方案嗎? group=1放在美學中。

ggplot(df, aes(x, y, color=z, group=1))+geom_point(size=3) +geom_line(size =1)+
  scale_y_discrete(limits=rev)

在此處輸入圖像描述

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM