Remove all axis values and labels in twoord plot

社会主义新天地 提交于 2019-12-10 10:38:35

问题


I want to remove all the axis including x, left and right y but retain the boundary of the plot. I tried to set xaxt and yaxt to 'n' but no luck.

library(plotrix)

twoord.plot(2:10,seq(3,7,by=0.5)+rnorm(9),
        1:15,rev(60:74)+rnorm(15),
        type=c("bar","l"), 
        xaxt='n',
        yaxt='n')

Is there any suggestion? Thanks in advance.


回答1:


I don't think so from what I saw. It's easy enough to create this plot anyway:

library('plotrix')
set.seed(1)
x1 <- 2:10
y1 <- seq(3,7,by=0.5)+rnorm(9)
x2 <- 1:15
y2 <- rev(60:74)+rnorm(15)

par(mfrow = c(1, 3), mar = c(3, 3,2,3))
twoord.plot(x1, y1, x2, y2, type=c("bar","l"), xaxt='n', yaxt='n', mar = c(3, 3,2,3))

## to recreate
plot(x1, y1, type = 'n', xlim = range(x2), ylim = range(y1))
rect(x1 - .4, 0, x1 + .4, y1, col = 'black')
par(new = TRUE)
plot(x2, y2, type = 'l', col = 'red', axes = FALSE)
axis(4, col.axis = 'red')

## again with no axes
plot(x1, y1, type = 'n', xlim = range(x2), ylim = range(y1), axes = FALSE)
rect(x1 - .4, 0, x1 + .4, y1, col = 'black')
par(new = TRUE)
plot(x2, y2, type = 'l', col = 'red', axes = FALSE)
box()



来源:https://stackoverflow.com/questions/29444096/remove-all-axis-values-and-labels-in-twoord-plot

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!