Search code examples
rr-grid

How to remove the ticks from a grid.yaxis


I need to remove the ticks and major line from a generated axis using grid.yaxis. According to ?grid.yaxis there is an "edits" parameter that will let me configure the "major", "ticks" and "labels".

However, I cant find how to use the edits parameter.

Here's some example code that will draw an axis in the center.

grid_test_axis <- function ()
{
    grid.newpage()
    vplayout <- function(x,y)
    viewport(layout.pos.row=x,layout.pos.col=y)

    pushViewport( viewport( layout=grid.layout( nrow=3, ncol=3, widths=c(1,1,1), heights=c(1,1,1)) ) )  
    pushViewport(viewport(layout.pos.col=1, clip="on"))
    grid.rect(gp=gpar(fill="red"))
    popViewport()
    pushViewport(viewport(layout.pos.col=3, clip="on"))
    grid.rect(gp=gpar(fill="brown"))
    popViewport()
    pushViewport(viewport(layout.pos.row=1,layout.pos.col=2))
    grid.rect(gp=gpar(fill="yellow"))
    popViewport()
    pushViewport(viewport(layout.pos.row=3,layout.pos.col=2))
    grid.rect(gp=gpar(fill="blue"))
    popViewport()
    pushViewport(viewport(layout.pos.row=2,layout.pos.col=2))
    pushViewport(viewport(layout=grid.layout(nrow=1, ncol=2)))  
    pushViewport(viewport(layout.pos.row=1,layout.pos.col=2))
    grid.yaxis(main=TRUE, at=seq(.1, .9, length=5))
    popViewport(3)
}

I would like to just stay with the numbers, not the ticks or major line.

Thanks.


Solution

  • Try this:

    grid.yaxis(name="ya", main=TRUE, at=seq(0.1, 0.9, length=5))
    grid.remove(gPath("ya", "ticks"))
    grid.remove(gPath("ya", "major"))