• 双坐标轴柱状图


    双坐标轴柱状图

    setwd(“H:/分析评价 20220531/6-分析过程”) #设置工作路径
    library(xlsx)#加载excel文件包
    #----------------------------------------------------------------------------------------------------------
    tiff(file=“1-占比.tiff”,res=600,width=6000,height=4000,compression=“lzw”) #设置输出图片名称
    par(mar=c(6, 6, 6, 6) + 0.1)
    a= read.xlsx(“2-计算数据.xlsx”,sheetIndex = 1) #读取excel文件

    Plot first set of data and draw its axis

    b <- seq(1,21,1)
    plot(b,a$小计.01.,pch=16, axes=FALSE, ylim=c(0,700), xlab=“”, ylab=“”,
    type=“b”,col=“black”,font.axis = 1,lwd=2)
    axis(2, ylim=c(0,700),col=“black”,las=2,family = “serif”,font.axis = 2,lwd=2,cex.axis=1.5) ## las=1 makes horizontal labels
    mtext(“面积(万亩)”,side=2,line=3,family = “serif”,font = 2,cex = 2)
    box(lwd=2)

    Allow a second plot on the same graph

    par(new=TRUE)

    Plot the second plot and put axis scale on right

    plot(b, a$占比.01., pch=15, xlab=“”, ylab=“”, ylim=c(0,30),
    axes=FALSE, type=“h”, col=“#63C600FF”,family = “serif”,font.axis = 1,lwd=15)

    a little farther out (line=4) to make room for labels

    axis(4, ylim=c(0,30), col=“#63C600FF”,col.axis=“#63C600FF”,las=2,family = “serif”,lwd=2,cex.axis=1.5)
    mtext(“占比(%)”,side=4,col=“#63C600FF”,line=3,family = “serif”,font = 2,cex = 2)

    Draw the time axis

    axis(1,pretty(range(b),21),family = “serif”,font.axis = 2,lwd=2,cex.axis=1.5)

    Add Legend

    legend(“topright”,legend=c(“面积”,“占比”), text.col=c(“black”,“#63C600FF”),pch=c(16,15),col=c(“black”,“#63C600FF”),text.font =10,bty=“n”)
    dev.off()
    在这里插入图片描述

  • 相关阅读:
    张家口城市名片欧洲推介会暨贸易促进会(荷兰站)在张家口顺利举行
    汇编语言与微机原理 期末半开卷复习整理(上)
    一桩字符串长度引发的惨案
    Pycharm配置Git以及Gitee实现代码管理(全网最详细)
    mongodb 索引实操
    实现简单的shared_ptr
    追问+初心阅读笔记
    【Linux】信号量
    原码,反码,补码以及计算
    C++基础——static成员
  • 原文地址:https://blog.csdn.net/weixin_45126863/article/details/128005598