我有一個用R中的swimplot包構建的游泳圖,并希望用資料框架中另一個變數的因子/文本來注釋每個條形圖,該變數屬于相應的ID/病人。
我不能分享資料,但以下是我目前正在撰寫的代碼,最后一行是我的失敗注釋(Best.response.1是各自文本變數的名稱)。 "id "是病人變數,"dayuntildeath "是時間變數。
plot3 < - swimmer_plot(df=data 。 id='id'/span>。 end='daysuntildeath',
width=.85, name_fill="Drug.1 ", id_order="Drug.1")
scale_fill_manual(name="Drug.1 "。 值 = c("coral1"。 "lavenderblush4", "maroon4"。 "springgreen3" , "springgreen4", "yellowgreen", "dodgerblue2"))
##################### 添加符號的審查#############################
###審查
plot4 <- plot3 swimmer_points(/span>df_points=)
data,id='id'。 時間='dayuntildeath',name_shape =
'event',size=2. 5,fill='white'>。 col='black')。
p4_new = plot4 scale_y_discrete(expand = c(0. 15。 0) labs(y = "Days until death")
geom_text(x = "id"。 y = "dayuntildeath"。 aes(label = "Best. 回應.1 "),vjust = -0。 2, color = "black")
編輯:沒有選項可以重命名病人的變數/刻度線。ID必須是可見的,只有添加注解才是可能的。
uj5u.com熱心網友回復:
總結一下要點:
geom_text使用了x和y引數在aes()函式中ggplot2中通常不加引號所以最后一行代碼應該是:
p4_new = plot4 scale_y_discrete(expand = c(0. 15,0)
labs(y = "day until death")
geom_text(aes(x = id, y = daysuntildeath, label = Best. 回應.1 ),
vjust = -0。 2, color = "black")
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/318950.html
標籤:
上一篇:每個單位有輪廓的柱狀圖?
