簡體   English   中英

連接 ggplot2 中 geom_jitter 點的線

[英]lines to connect geom_jitter points in ggplot2

我正在嘗試連接geom_jitter()的點。

 df<-data.frame(x = c(1, 1, 2, 2, 3, 3), 
           y = c(1, 1, 2 , 3, 6, 5), 
           z = c("A", "B", "A", "B", "A", "B")) 
ggplot(df, aes(x = x, y = y, col = z)) + 
  geom_jitter() + 
  geom_line()

現在線和點沒有連接。

library(dplyr)
ggplot(df %>% mutate(x = jitter(x), y = jitter(y)), 
       aes(x = x, y = y, col = z)) + 
  geom_point() + 
  geom_line()

在此處輸入圖片說明

將抖動(一些偏差)添加到您的數據中,然后繪制有偏差的數據。

暫無
暫無

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

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