簡體   English   中英

如何更改ggboxplot上的x軸刻度?

[英]How to change the x-axis ticks on ggboxplot?

我有一個看起來像這樣的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.

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