代码之家  ›  专栏  ›  技术社区  ›  yenats

条形图中阴影线的宽度

  •  3
  • yenats  · 技术社区  · 9 年前

    我用R中的以下脚本创建了一个条形图:

    bars <- c(229, 158)
    shading.lines <- c(83, 83)
    years <- c("1985-89", "2017")
    cols1 <- c("indianred4","green4")
    cols2 <- c("green4","indianred4")
    barplot(bars,names.arg=years,col=cols1)
    barplot(shading.lines,names.arg=NA,col=cols2,density=11,add=T)
    

    enter image description here

    1 回复  |  直到 9 年前
        1
  •  2
  •   Marco Sandri    9 年前

    可以使用调整着色的宽度 par(lwd=...)

    bars <- c(229, 158)
    shading.lines <- c(83, 83)
    years <- c("1985-89", "2017")
    cols1 <- c("indianred4","green4")
    cols2 <- c("green4","indianred4")
    barplot(bars,names.arg=years,col=cols1)
    # Set width of shading
    par(lwd=5)
    barplot(shading.lines,names.arg=NA,col=cols2,density=11,add=T)
    # Set width of shading to the default value
    par(lwd=1)
    

    enter image description here