R2-38-第三期ggplot2画柱状图

jinhui 2017-11-18 13:41:03 阅读: 979

setwd("D:/projects/R learning/week 3 data")

library(ggplot2)

library(ggthemes)

library(reshape2)

data1 <- read.csv("R2-3.1.csv", header = T)

data1 <- melt(data1, id.vars = 'Products', 

              measure.vars = c("Q1th", 'Q2nd', 'Q3rd','Q4th'),

              variable.name = 'products', value.name = 'value')

graph1 <- ggplot(data1, aes(x=variable, y= value, fill = Products))+

    geom_bar(stat="identity", position="dodge", color= "black") +

    labs(x="Time", y="Index")+ ggtitle("R2-38")+

  scale_fill_wsj("rgby")+theme_wsj(color="blue") 


data2 <- read.csv("R2_3_2.csv", header = T)

graph2 <- ggplot(data2, aes(社区, fill = 态度))+

  geom_bar(position="stack") +

   ggtitle("R2-38")+coord_flip()+

  labs(x="count", y="社区")+

  scale_fill_brewer(palette = "Pastel1")

graph_1.png


graph2.png

 
邀请讨论

附件

{{f.title}} 大小 {{f.file_size}} 下载 {{f.count_download}} 金币 {{f.count_gold}}
{{item.nick_name}} 受邀请回答 {{item.create_time}}
{{item.refer_comment.nick_name}} {{item.refer_comment.create_time}}

附件

{{f.title}} 大小 {{f.file_size}} 下载 {{f.count_download}} 金币 {{f.count_gold}}
切换到完整回复 发送回复
赞({{item.count_zan}}) 踩({{item.count_cai}}) 删除 回复 关闭
科研狗©2015-2024 科研好助手,京ICP备20005780号-1 建议意见

服务热线

178 0020 3020

微信服务号