R 在图形之间绘制一致的颜色
我不明白为什么要用颜色。特别是,如何在不同类型的图形中获得相同的颜色。在代码的早期,我定义了R 在图形之间绘制一致的颜色,r,ggplot2,R,Ggplot2,我不明白为什么要用颜色。特别是,如何在不同类型的图形中获得相同的颜色。在代码的早期,我定义了 colorscheme = scale_fill_brewer(type="qual",palette = 3) theme.noframe = theme(panel.background = element_rect(fill = 'transparent'), legend.key=element_rect(fill='transparent'),
colorscheme = scale_fill_brewer(type="qual",palette = 3)
theme.noframe = theme(panel.background = element_rect(fill = 'transparent'),
legend.key=element_rect(fill='transparent'),
legend.title=element_blank(),
axis.line = element_line(color="black",linetype="solid"),
axis.text.x = element_text(color = 'black'),
axis.text.y = element_text(color='black'),
axis.title.x = element_text(colour = 'black'),
axis.title.y = element_text(colour = 'black'))
稍后我有以下内容
ggplot(df, aes(x=Date, y=value/Divisor, fill=Fill)) +
geom_area(position="stack") + xlab("") + theme.noframe + colorscheme +
scale_x_date( labels=date_format("%Y"),breaks = date.seq ) +
ylab(paste("AUM (",LabelScale,")"))
产生
然后我打电话
ggplot(df, aes(x=Date, y=value/Divisor, color=Fill)) +
geom_line() + xlab("") + theme.noframe + colorscheme +
scale_x_date( labels=date_format("%Y"),breaks = date.seq ) +
ylab(paste("AUM (",LabelScale,")"))
然后我明白了
调用之间的两个区别是1)geom_line替换geom_区域,2)color=Fill替换Fill=Fill
您会注意到,对于每个类别,线条颜色都不同于区域颜色。如何更改“ggplot”调用以使颜色一致?请考虑
colorscheme <- list(
scale_fill_brewer(type="qual",palette = 3),
scale_color_brewer(type="qual",palette = 3) )
colorscheme考虑
colorscheme <- list(
scale_fill_brewer(type="qual",palette = 3),
scale_color_brewer(type="qual",palette = 3) )
colorscheme您应该看看scale\u color\u*
和scale\u fill\u*
一组ggplot
函数。您可能会在这些函数中使用值
参数。此链接可能会有所帮助。您应该查看ggplot
函数的scale\u color\u*
和scale\u fill\u*
集合。您可能会在这些函数中使用值
参数。这个链接可能会对这项工作有所帮助!然而,我不能说为什么缩放填充不同于缩放颜色,以及我应该在什么时候使用它。color
和fill
是两种不同的美学<代码>颜色
主要应用于线条或边框颜色,填充区域的颜色。这很有效!然而,我不能说为什么缩放填充不同于缩放颜色,以及我应该在什么时候使用它。color
和fill
是两种不同的美学<代码>颜色
主要应用于线条或边框颜色,填充区域的颜色。