[英]How to change the x-axis ticks on ggboxplot?
我有一個看起來像這樣的ggboxplot:
我想將箱線圖的 x 軸刻度更改為“不受控制的疾病”和“受控疾病”,而不是“進行性”和“穩定”。 我嘗試使用 scale_x_discrete:
ggboxplot(inf, x = "DiseaseStatus", y = "log.IL-1RA",
color = "DiseaseStatus", palette = c("#00AFBB", "#E7B800"),
ylim = c(-2,8),
order = c("Progressive", "Stable"),
scale_x_discrete(labels = c("Uncontrolled Disease", "Controlled Disease")),
main = "IL-1RA",
ylab = "log lab value", xlab = "DiseaseStatus")
但我得到這個錯誤:
Error in !is.null(facet.by) | combine :
operations are possible only for numeric, logical or complex types
我究竟做錯了什么? 是否可以更改 x 軸刻度?
這應該可以解決問題!
ggboxplot(inf, x = "DiseaseStatus", y = "log.IL-1RA",
color = "DiseaseStatus", palette = c("#00AFBB", "#E7B800"),
ylim = c(-2,8),
order = c("Progressive", "Stable"),
main = "IL-1RA",
ylab = "log lab value", xlab = "DiseaseStatus") +
scale_x_discrete(labels = c("Uncontrolled Disease", "Controlled Disease"))
我使用了測試數據,因為我沒有你的數據。 這是我使用的代碼
library(ggpubr)
data("ToothGrowth")
df <- ToothGrowth
ggboxplot(df, x = "dose", y = "len", width = 0.8) +
scale_x_discrete(labels = c("Uncontrolled Disease", "Controlled Disease", "third variable"))
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.