【问题标题】:Changing the order in this plot [duplicate]更改此图中的顺序[重复]
【发布时间】:2021-01-13 23:03:33
【问题描述】:

我有这个数据和代码,我有这个情节

在情节中,您会看到无响应者先来,然后响应者来

在代码中我看不到如何更改组

                                                                                                                                                                                                                                          "Non-responders")), row.names = c(NA, -22L), class = "data.frame")
library(dplyr)
library(ggplot2)
library(ggrepel)

x <- x %>%
  rename(log10_qvalue = log10_pvalue)

ggplot(data = x, aes(x = log10_qvalue, y = Percentage_altered/100, color = CNV)) +
  geom_point( ) +
  scale_discrete_manual(aesthetics = "colour", values = c("Deletion" = "blue", "Amplification" = "red")) +
  geom_text_repel(aes(label = gene), size = 5) +
  facet_grid(CNV ~ group) +
  labs(x = "-log10(qvalue)", y = "Net frequency of gain and deletion (%)") +
  theme_bw() +
  theme(
    legend.position = "none",
    axis.title = element_text(size = 12, face = "bold"),
    axis.text = element_text(size = 12, face = "bold"),
    strip.text = element_text(size = 12, face = "bold")
  )

如何更改此代码以使第一响应者进入左侧,非响应者进入右侧?

【问题讨论】:

    标签: r ggplot2 dplyr tidyverse


    【解决方案1】:

    将组更改为“因素”。这样顺序是由因子中的顺序而不是字母顺序定义的。

    x$group <- factor(x$group, levels = c("Responders", "Non-responders"))
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-07-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-09-17
      • 2018-03-18
      • 1970-01-01
      相关资源
      最近更新 更多