[英]Colour gradient in bubble plot
我正在根據閾值定義顏色。 但是有沒有辦法給出顏色漸變?
df %>%
mutate(X_value = 'Term') %>%
ggplot(aes(x=X_value,y=p_value)) +
geom_point(aes(size=abs(p_value)),
color = dplyr::case_when(df$p_value > -6 ~ "red",
df$p_value < 6 ~ "blue")) +
geom_label_repel(aes(label=Pathway), size=3) +
labs(y=NULL, x = NULL,color='p_value',size='p_value'
這段代碼
ggplot(df, aes(x=p_value,y=Term)) +
geom_point(aes(color=p_value,size=p_value)) +
scale_color_gradientn(colours = rainbow(5)) +
labs(
x='p_value', y=NULL,
color='p_value',size='p_value'
) +
theme(
axis.title = element_text(face='bold'),
axis.text = element_text(face='bold')
)
給我這個
我想擁有第一個,並且我想放一個在第二張圖片中看到的顏色漸變。 不知道怎么做,因為第一個圖閾值是基於一個標記它的截止值。
我的數據
structure(list(Term = c("Reactome Gene Sets", "GO Biological Processes",
"GO Biological Processes", "GO Biological Processes", "GO Biological Processes",
"GO Biological Processes"), Pathway = c("R-MMU-191273", "GO:0034341",
"GO:0050900", "GO:0046942", "GO:0001817", "GO:0048871"), VVV = c("Cholesterol biosynthesis",
"response to interferon-gamma", "leukocyte migration", "carboxylic acid transport",
"regulation of cytokine production", "multicellular organismal homeostasis"
), p_value = c(-11.6414922875, -9.3148301923, -6.2150336681,
-5.9190690396, -5.8467499202, -5.767770517)), row.names = c(NA,
-6L), class = c("tbl_df", "tbl", "data.frame"))
任何建議或幫助將不勝感激
您可以在其中一個類別上使用漸變,並使用灰色作為另一個類別,例如
df %>%
mutate(X_value = "Term") %>%
ggplot(aes(x = X_value, y = p_value)) +
geom_point(aes(size = abs(p_value), color = p_value)) +
geom_label_repel(aes(label = Pathway), size=3) +
labs(y = NULL, x = NULL) +
scale_color_gradientn(colours = rainbow(5), limits = c(-12, -6), breaks = c(-6, -12))
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.