如何在基准R中调整pch绘图点的轮廓大小?

时间:2019-03-30 16:22:37

标签: r plot colors cex

我正在调整基本R绘图中的cex选项,以调整演示幻灯片的绘图大小。我似乎可以调整大多数尺寸方面,但是当打印点变大时,我注意到我的pch点的轮廓颜色没有变粗/变粗。因此,绘图点越大,轮廓线颜色越不明显。

在各种cex选项(cex,cex.main,cex.sub,cex.axis,cex.lab)上找到了许多网站(有SO帖子),但似乎没有一个网站可以调整pch绘图点。

我知道只有某些pch符号(21到25)可以与填充颜色和轮廓一起使用。我的示例代码使用21(圆圈)。

data("mtcars")  # test data
summary(mtcars[c("hp","mpg")]) # to find on min & max values to set plot limits

# set general features used for multiple plots
par(bg="blue", fg="red", col="yellow", col.axis="white", col.lab="white", bty="n", cex=1.5)

# test plot to illustrate, cex used here to further adjust plot points from par setting
plot(mtcars$hp, mtcars$mpg, ylim=c(10, 35), xlim=c(50, 340), pch=21, bg="red", cex=2) 

我是否缺少有关cex的信息,或者是否有其他解决方案而不转向ggplot?如果可以的话,我对ggplot并不不利,但是我想看看它是否可以在base R中完成。

1 个答案:

答案 0 :(得分:3)

您需要指定lwd来更改pch符号的边框粗细

plot(1:10, 1:10, pch = 21, cex = 3, lwd = 1:10)

enter image description here