我有这个矩阵
CL r1 r2 r3 r4 r5 r6
[1,] 25 0 1 0 0 1 0
[2,] 30 5 3 1 1 1 1
[3,] 35 1 0 1 0 0 1
[4,] 40 0 0 0 0 0 0
我想以这种方式绘制它(来自excel示例)
和
我能用ggplot2
做到吗?或与其他包裹?
答案 0 :(得分:0)
对于第二个情节:
library(reshape2)
library(ggplot2)
df_series<-as.data.frame(matrix_series)
colnames(df_series)<-c("CL", "Series1","Series2","Series3","Series4","Series5", "Series6")
df_series.tall<-melt(df_series, id.vars="CL")
ggplot(df_series.tall, aes(x=CL,y=value, color=variable))+geom_smooth()
1st plot :
ggplot(df_series.tall, aes(x=variable,y=value, fill=factor(CL)))+geom_bar(stat="identity", position="dodge")