R Ggplot2-简单图例和颜色
我知道ggplot2使用了图形语法的概念。在这里,我尝试使用一个带有简单图例的分层着色方案,但我没有获得太多成功。我希望下面的第一个geom_点()全部为黑色,第二个全部为蓝色(仅用于统计显著点),第三个为红色。对于传说,我希望黑色是“不重要的”,蓝色是“重要的”,红色是“公布的基因”。有人能帮忙或提供一些建议吗R Ggplot2-简单图例和颜色,r,ggplot2,R,Ggplot2,我知道ggplot2使用了图形语法的概念。在这里,我尝试使用一个带有简单图例的分层着色方案,但我没有获得太多成功。我希望下面的第一个geom_点()全部为黑色,第二个全部为蓝色(仅用于统计显著点),第三个为红色。对于传说,我希望黑色是“不重要的”,蓝色是“重要的”,红色是“公布的基因”。有人能帮忙或提供一些建议吗 gene_count.poly <- ggplot() + labs(title="Poly Untreated vs. Treated&quo
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)
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"))
谢谢,这完美地回答了我的问题。