【问题标题】:R: barplot: space between outer bars and the plotting areaR:barplot:外条和绘图区域之间的空间
【发布时间】:2018-04-20 10:38:22
【问题描述】:

我有一段代码如下:

par(mar=c(0.1, 15, 0.5, 15))
barplot(dat[[1]][, 2], beside=TRUE, axes=FALSE, ylim=ylim.axis_left, space=0, col="#808080")
box()

生成此图:

我想去掉左/右栏和绘图区域之间的空间,用 box() 标记。我玩了一点边距,但这不是解决方案,因为它们缩小了绘图区域本身,但空间仍然存在......

【问题讨论】:

    标签: r plot graphics bar-chart


    【解决方案1】:

    在没有可重现示例的情况下,我采用了 mtcars 数据

    barplot(mtcars$cyl, axes=FALSE, space=0, col="#808080")
    box()
    

    当您如下设置xaxsyaxs 时,您会注意到绘图两侧的默认边距消失了。

    barplot(mtcars$cyl, axes=FALSE, space=0, col="#808080", xaxs="i", yaxs="i")
    box()
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-06-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多