r - 如何调整基本 R 中 pch 绘图点轮廓的大小?

标签 r plot colors

我正在修改基本 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,但我想看看它是否可以在基础 R 中完成。

最佳答案

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

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

enter image description here

关于r - 如何调整基本 R 中 pch 绘图点轮廓的大小?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55433423/

相关文章:

r - 如何引用 dplyr 中的其他列名 mutate across

r - 提取stat_smooth线拟合的方法

python - 有没有一种简单的方法可以在通过自定义函数(楔形)显示数据的 matplotlib 图上使用对数刻度?

matlab - 从 3 个向量创建等高线图

java - 将 Pantone 颜色转换为 RGB?

c++ - 比较 Rcpp 中的两个值而不强制转换为特定类型

python - Jupyter 笔记本 rpy2 Rmagics : How to set the default plot size?

html - CSS中具有多种颜色渐变的文本

c# - 从 .net 将图像写入每 channel 32 位(每像素 128 位)位图

r - 将函数应用于数据框中的所有偶数值