[英]How to make ggplot colors more distinct and colorblind friendly?
toLonger <- function(expressionMatrix) {
expressionMatrix <- longExpressionMatrix <- expressionMatrix %>%
as.data.frame() %>%
rownames_to_column("gene") %>%
pivot_longer(cols = !gene,
values_to = "Expression",
names_to = "sample_id")
return(expressionMatrix)
}
toLonger(dge_cpmlogtwo) %>%
ggplot(aes(x = Expression, color = sample_id)) +
geom_density() +
theme(axis.text.x = element_text(angle = 90, hjust = 1))
I want to make the colors in the third last line stand out more?我想让倒数第三行的colors更加突出? I found this reply but was not able to understand how to apply it to my code.
我找到了这个回复,但无法理解如何将它应用到我的代码中。
Lastly is there a way to ensure my plots will be color blind frinedly?最后有没有办法确保我的地块是色盲的?
Regarding colorblind friendly palettes, you could consult these two links which address the issue:关于色盲友好调色板,您可以参考这两个解决问题的链接:
I don't have access to your data, but you should be able to click around to find a palette you like, and apply it to your ggplot with the info linked above, good luck!我无权访问您的数据,但是您应该可以单击以找到您喜欢的调色板,然后使用上面链接的信息将其应用于您的 ggplot,祝您好运!
Here's an example of how it might apply to your case:这是一个如何适用于您的案例的示例:
toLonger(dge_cpmlogtwo) %>%
ggplot(aes(x = Expression, color = sample_id)) +
geom_density() +
scale_color_brewer(palette="BrBG") +
theme(axis.text.x = element_text(angle = 90, hjust = 1))
Also it is aparently not very clear how to find the palette codes in question, eg BrBG
, but one way would be like this:此外,如何找到有问题的调色板代码显然不是很清楚,例如
BrBG
,但一种方法是这样的:
palette=
argument for eg.palette=
参数一起使用,例如。 scale_color_brewer
, like I have done above. scale_color_brewer
,就像我在上面所做的那样。 See this image to see what I mean, on it I have the cookbook-r.com and colorbrewer2.org pages from above opened in two windows.请参阅此图像以了解我的意思,在上面我有两个 windows 中打开的上面的食谱-r.com 和 colorbrewer2.org 页面。 Red rectangular highlight is added by me:
红色矩形高光是我加的:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.