【问题标题】:How to I resize the outline of a pch plot point in base R?如何在基础 R 中调整 pch 绘图点的轮廓?
【发布时间】:2019-08-21 08:07:45
【问题描述】:

我正在修改基本 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中完成。

【问题讨论】:

    标签: r plot colors


    【解决方案1】:

    你需要指定lwd来改变pch符号的边框粗细

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

    【讨论】:

    • 谢谢!让我觉得自己像个新手。我正在使用 lwd 来调整我添加到绘图中的其他元素,例如 abline,但实际上并没有尝试将其放入绘图或 par 函数中。再次感谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-07-03
    • 1970-01-01
    • 2021-09-07
    • 1970-01-01
    • 1970-01-01
    • 2020-11-23
    • 1970-01-01
    相关资源
    最近更新 更多