为 Y 标签 ggplot R 设置颜色
Set up colours for Y label ggplot R
如何设置下一张图片的颜色?我想为所有引用相同数字的点(1
的所有点、一种颜色、2
的所有点、另一种颜色......所有子图。
这是我的代码:
D = melt(Y2, id='Row.Names')
p5 = ggplot(D, aes(x=factor(Row.Names), y=value, group=variable, colour=variable))
p5 + geom_point() + facet_wrap(~variable, scale="free") +
theme(legend.position = 'none')
试试这个方法,下次请附上您的数据样本。使用组美学元素,您可以拥有相同的颜色。这里的代码可以使用虚拟数据框适合您的真实数据(我增加了点大小以查看颜色如何相等):
library(ggplot2)
#Data
df <- data.frame(var=c(rep('Danceability',3),rep('energy',3),rep('key',3)),
value=rnorm(9,1,2),
id=factor(rep(c(1,2,3),3)))
#Plot
ggplot(df,aes(x=id,y=value,color=id,group=id))+
geom_point(size=3,show.legend = F)+
facet_wrap(.~var, scale="free")
输出:
如何设置下一张图片的颜色?我想为所有引用相同数字的点(1
的所有点、一种颜色、2
的所有点、另一种颜色......所有子图。
这是我的代码:
D = melt(Y2, id='Row.Names')
p5 = ggplot(D, aes(x=factor(Row.Names), y=value, group=variable, colour=variable))
p5 + geom_point() + facet_wrap(~variable, scale="free") +
theme(legend.position = 'none')
试试这个方法,下次请附上您的数据样本。使用组美学元素,您可以拥有相同的颜色。这里的代码可以使用虚拟数据框适合您的真实数据(我增加了点大小以查看颜色如何相等):
library(ggplot2)
#Data
df <- data.frame(var=c(rep('Danceability',3),rep('energy',3),rep('key',3)),
value=rnorm(9,1,2),
id=factor(rep(c(1,2,3),3)))
#Plot
ggplot(df,aes(x=id,y=value,color=id,group=id))+
geom_point(size=3,show.legend = F)+
facet_wrap(.~var, scale="free")
输出: