[英]Ggplot2 - Simple Legend and Coloring
我了解 ggplot2 使用圖形語法的概念。 在這里,我嘗試使用帶有簡單圖例的分層着色方案,但我並沒有取得太大的成功。 我希望下面的第一個 geom_point() 全部為黑色,第二個全部為藍色(僅用於統計顯着點),第三個為紅色。 對於傳說,我希望黑色是“不重要的”,藍色是“重要的”,紅色是“已發表的基因”。 任何人都可以提供幫助或提供一些建議嗎?
gene_count.poly <-
ggplot() +
labs(title="Poly Untreated vs. Treated",
x ="log2(Poly Untreated)", y = "log2(Poly Treated)") +
geom_point(data=normalized_all_counts.poly, aes(x=log2(avg_rep1),
y=log2(avg_rep2)), color="black") +
geom_point(data=significant_normalized_all_counts.poly, aes(x=log2(avg_rep1),
y=log2(avg_rep2)), color="blue") +
geom_point(data=significant_normalized_all_counts.poly, aes(x=log2(avg_rep1),
y=log2(avg_rep2)), color = significant_normalized_all_counts.poly$genecolor)
print(gene_count.poly)
這是您使用內置mtcars
數據集描述的示例。
library(ggplot2); library(dplyr)
ggplot(mtcars, aes(wt, mpg)) +
geom_point(data = filter(mtcars, mpg > 25),
aes(color = "high mpg")) +
geom_point(data = filter(mtcars, wt > 5),
aes(color = "high weight")) +
geom_point(data = filter(mtcars, wt == 3.44),
aes(color = "one particular weight")) +
scale_color_manual(values = c("high mpg" = "black",
"high weight" = "blue",
"one particular weight" = "red"))
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.