如何只删除R cdplot中的左轴标签?

时间:2013-02-04 16:30:02

标签: r graphics

附加的示例生成条件密度图。在示例中,我可以使用ylab = NA删除“x”轴标签,如果我使用yaxlabels = "n",则会删除左右刻度标签。

如何仅抑制左标签(即“0”和“1”)并保持右手概率标度?

# Example
Forest = c(1,0,1,1,1,0,1,1,0,1)
change = c(-1, 3, 1, 4, 1, 1, -1, 1, -1, 6)
mydata = data.frame(Forest,change)

x = factor(mydata$Forest)

cdplot(x~mydata$change, ylab = NA, xlab = NA)

enter image description here

1 个答案:

答案 0 :(得分:4)

正如您所说,您可以使用yaxlabels = "n"删除双方的y标签。 而不仅仅是通过axis(4)添加右侧轴。

Forest = c(1,0,1,1,1,0,1,1,0,1)
change = c(-1, 3, 1, 4, 1, 1, -1, 1, -1, 6)
mydata = data.frame(Forest,change)

x = factor(mydata$Forest)

cdplot(x~mydata$change, ylab = NA, xlab = NA, yaxlabels = "n")
axis(4)

enter image description here