ggplot2 双纵坐标图

所用数据详情
Year Title Allfield
1 2001 43 405
2 2002 39 452
3 2003 50 632
4 2004 78 903
5 2005 90 1192
6 2006 119 1575
7 2007 180 1956
8 2008 171 2360
9 2009 200 2901
10 2010 210 3579
11 2011 252 4276
12 2012 238 5171
13 2013 343 6092
14 2014 349 6953
15 2015 379 8020
16 2016 452 9163
17 2017 538 10345
18 2018 574 12342
19 2019 775 15592
20 2020 796 16264

所用代码

library(readr)
library(ggplot2)
referencefigure2 <- read_csv("referencefigure2.csv") #加载数据

cut <- 20 # 考虑到次坐标轴和主坐标轴为20倍数关系
p <- ggplot(referencefigure2,aes(x=Year)) + 
  geom_line(aes(y=Title,colour="在标题、摘要、关键字")) +
  geom_line(aes(y=Allfield/cut,colour="在所有字段")) + 
  scale_y_continuous(limits = c(0,800),breaks = seq(0,800,100), name = "Scopus数据库相关论文数量",sec.axis = sec_axis(~.*cut,breaks = c(seq(0,17000,3000),17000)))+
  scale_x_continuous(limits = c(2001,2020),breaks=c(2001,2005,2010,2015,2020)) +
  theme(legend.position = "top")

ggsave('figure1.tiff', p, width=133, height=100, units="mm") # 保存为tiff 设置大小

所得图像为
在这里插入图片描述

  • 2
    点赞
  • 16
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值