如何更改基础 R 图表区域的背景颜色?
若要更改基础 R 图表区域的背景颜色,我们可以按照以下步骤进行 −
首先,在基础 R 中创建一个图表以了解差异。
然后,使用带有 bg 参数的 par 函数,你可以在其中放入颜色名称,然后创建相同的图表。
示例
创建图表
让我们在基础 R 中创建一个条形图,如下所示 −
x<-sample(1:10,3) barplot(x)
输出
创建带有更改背景颜色的图表
使用带有黄色 bg 参数的 par 函数,然后创建条形图 −
x<-sample(1:10,3) par(bg="yellow") barplot(x)
Explore our latest online courses and learn new skills at your own pace. Enroll and become a certified expert to boost your career.
输出
广告