前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >ggplot2折线图展示美国和印度COVID-19单日新增确诊人数变化趋势

ggplot2折线图展示美国和印度COVID-19单日新增确诊人数变化趋势

作者头像
用户7010445
发布2020-07-24 15:50:37
5450
发布2020-07-24 15:50:37
举报

数据来源

代码

代码语言:javascript
复制
df<-read.csv("../../WHO-COVID-19-global-data.csv",header=T,
             stringsAsFactors = F)
head(df)
df1<-df[df$Country_code=="US"|df$Country_code=="IN",]
head(df1)
table(df1$Country_code)
table(df1$Country)
library(ggplot2)
df2<-na.omit(df1)
x_labels<-paste("2020-0",1:7,"-11",sep="")
x_labels
ggplot(df2,aes(x=Date_reported,y=New_cases,group=Country_code))+
  geom_point(aes(color=Country_code))+
  geom_line(aes(color=Country_code))+
  scale_x_discrete(breaks=x_labels,
                   labels=x_labels)+
  theme_bw()+
  ggtitle("美国和印度每日新增确诊人数")+
  theme(legend.title = element_blank(),
        legend.position = "top",
        plot.title = element_text(hjust=0.5))+
  labs(x="",y="")+
  scale_color_manual(values=c("red","blue"))+
  scale_y_continuous(breaks=c(0,20000,40000,60000),
                     labels = c("0","2万","4万","6万"))

结果

本文参与 腾讯云自媒体分享计划,分享自微信公众号。
原始发表:2020-07-22,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 小明的数据分析笔记本 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 数据来源
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档