更改 R 图中图例的颜色
Changing the color of legend in plot for R
所以我在图表的图例中遇到了一个小问题。我似乎无法让 "RCB Class 1,2 or 3" 显示为黑点而不是红点。我是 R 的新手并用 R 制作图表。请帮忙 :) 图片和代码附在下面。此外,如果有人知道如何缩小图例字体大小以及如何添加更多轴刻度线以使其以 10 秒为单位计数,请告诉我。
par(mar = c(6, 5, 5, 10), xpd = TRUE) # par 参数添加 space for legend
ERPR_plot <-- plot(mint$er_pct,mint$pr_pct,
xlab="ER Staining (%)",
ylab="PR Staining (%)",
xlim=range(0:100),
ylim=range(0:100),
main = "PR Percent Staining vs. ER Percent Staining",
col = ifelse(mint$pcr == 1,'red','black'),
panel.first = grid())
legend("topright", inset = c(- 0.45, 0), # Create legend outside of plot
legend = c("pCR","RCB Class 1,2 or 3"),
pch=1,
col="red","black")
我们可以通过连接 (c
) 两种颜色将 col
指定为向量
plot(mint$er_pct,mint$pr_pct,
xlab="ER Staining (%)",
ylab="PR Staining (%)",
xlim=range(0:100),
ylim=range(0:100),
main = "PR Percent Staining vs. ER Percent Staining",
col = ifelse(mint$pcr == 1,'red','black'),
panel.first = grid())
legend("topright", inset = c(- 0.45, 0),
legend = c("pCR","RCB Class 1,2 or 3"),
pch=1,
col=c("red","black"))
所以我在图表的图例中遇到了一个小问题。我似乎无法让 "RCB Class 1,2 or 3" 显示为黑点而不是红点。我是 R 的新手并用 R 制作图表。请帮忙 :) 图片和代码附在下面。此外,如果有人知道如何缩小图例字体大小以及如何添加更多轴刻度线以使其以 10 秒为单位计数,请告诉我。
ERPR_plot <-- plot(mint$er_pct,mint$pr_pct,
xlab="ER Staining (%)",
ylab="PR Staining (%)",
xlim=range(0:100),
ylim=range(0:100),
main = "PR Percent Staining vs. ER Percent Staining",
col = ifelse(mint$pcr == 1,'red','black'),
panel.first = grid())
legend("topright", inset = c(- 0.45, 0), # Create legend outside of plot
legend = c("pCR","RCB Class 1,2 or 3"),
pch=1,
col="red","black")
我们可以通过连接 (c
) 两种颜色将 col
指定为向量
plot(mint$er_pct,mint$pr_pct,
xlab="ER Staining (%)",
ylab="PR Staining (%)",
xlim=range(0:100),
ylim=range(0:100),
main = "PR Percent Staining vs. ER Percent Staining",
col = ifelse(mint$pcr == 1,'red','black'),
panel.first = grid())
legend("topright", inset = c(- 0.45, 0),
legend = c("pCR","RCB Class 1,2 or 3"),
pch=1,
col=c("red","black"))