R pyramid plot very slow if fed with larger numbers

前端 未结 1 1541
情歌与酒
情歌与酒 2021-01-21 10:51

I am trying make a pyramid plot with R. The I found a example code in the internet that does what I want. The problem is that I am not working with small numbers as in the examp

1条回答
  •  一整个雨季
    2021-01-21 11:08

    Internally, pyramid.plot is trying to do some stuff to finagle the axes accounting for the gap in the middle: if you do debug(pyramid.plot) and step through line-by-line you find where the problem is:

    if (is.null(laxlab)) {
                laxlab <- seq(xlim[1] - gap, 0, by = -1)
                axis(1, at = -xlim[1]:-gap, labels = laxlab)
            }
    

    in other words, pyramid.plot is trying to make an axis with ticks every 1 (!) unit. Something like this works OK:

    pyramid.plot(x,y,labels=groups,
                 main="Performance",gap=5e5,show.values=TRUE,
                 laxlab=seq(0,1e7,by=1e6),raxlab=seq(0,1e7,by=1e6))
    

    there are a few other vestiges of the fact that pyramid.plot was designed for demographic plots ... you might write to the package maintainer and ask him to think about generalizing the design of the axes a little bit ...

    0 讨论(0)
提交回复
热议问题