如何在基本 R 图中更改图例的背景颜色?
要在基本 R 中为绘图创建图例,我们可以使用 legend 函数,如果图例的背景颜色需要从白色更改为其他颜色,则将使用 legend 函数中的 bg 参数。例如,要将背景颜色更改为红色,我们可以使用 bg="red"。
示例 1
plot(1:10) legend("right",legend="point chart",bg="blue")
输出
Explore our latest online courses and learn new skills at your own pace. Enroll and become a certified expert to boost your career.
示例 2
plot(1:10) legend("right",legend="point chart",bg="light green")
输出
示例 3
plot(1:10) legend("left",legend="point chart",bg="light grey")
输出
广告