本文介绍了ggplot2:每个facet独立的色阶的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 直觉上我正在寻找类似于: facet_(scales =free_color) 类似于 p p + geom_jitter() 即:绘制个人的二维测量值(制造商)的物种,由物种表示,用颜色表示个体。 问题在于所有个体都具有相同的色阶 - 因此一个方面中的点具有非常相似的颜色。 使用geom_line的美学审美将解决问题,但线条讲的不同于点的故事。 另一个明显的解决方案是放弃刻面并为每个子集绘制一个单独的绘图。 (如果这应该是唯一的解决方案:是否有任何快速,聪明或经过证明的方式来做到这一点?) 不知道这是一个可用的选项,当你着色的因素。但是,生成单个图的快捷方式应该是这样的: d_ply(mpg,。(制造商),函数(df){ jpeg(paste(df $ manufacturer [[1]],.jpeg,sep =))图 print(plot) dev.off()}) 相关答案: 不同的图例和填充颜色为ggplot? a> Intuitively I'm looking for something like: facet_(scales="free_color")I do something likep <- ggplot(mpg, aes(year, displ, color=model)) + facet_wrap(~manufacturer)p + geom_jitter()That is: plot 2d measurements from individuals(model) belonging to different species(manufacturer) faceted by a species, indicating the individual by color.The problem is that all individuals share the same color scale - so that the points in a facet have very similar colors.Using the group aesthetic with geom_line would solve the problem, but lines tell different story than dots.Another obvious solution would be to drop the faceting and draw a separate plot for each subset. (If this should be the only solution: are there any quick, smart or proven ways to do that?) 解决方案 I'm not sure that this is an available option when you're colouring by a factor. However, a quick way to produce the individual plots would be something like this:d_ply(mpg, .(manufacturer), function(df) {jpeg(paste(df$manufacturer[[1]], ".jpeg", sep=""))plots <- ggplot(df, aes(year, displ, color=factor(model))) + geom_jitter()print(plots)dev.off()})Related Answers:Different legends and fill colours for facetted ggplot? 这篇关于ggplot2:每个facet独立的色阶的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-29 03:57