Ggplot2-background-colors

提供:Dev Guides
移動先:案内検索

ggplot2-背景色

以下で説明するように、1つの関数でプロット全体の外観を変更する方法があります。 しかし、あなたができるパネルの背景色を単に変更したい場合は、以下を使用してください-

パネル背景の実装

パネルの変更に役立つ次のコマンドを使用して背景色を変更できます(panel.background)-

> ggplot(iris, aes(Sepal.Length, Species))+geom_point(color="firebrick")+
+ theme(panel.background = element_rect(fill = 'grey75'))

色の変化は下の写真にはっきりと描かれています-

パネルの背景の実装

Panel.grid.majorの実装

以下のコマンドで言及されているように、プロパティ「panel.grid.major」を使用してグリッド線を変更できます-

> ggplot(iris, aes(Sepal.Length, Species))+geom_point(color="firebrick")+
+    theme(panel.background = element_rect(fill = 'grey75'),
+    panel.grid.major = element_line(colour = "orange", size=2),
+    panel.grid.minor = element_line(colour = "blue"))

実装パネルの背景

以下で説明するように、「plot.background」プロパティを使用して、特にパネルを除いてプロットの背景を変更することもできます-

ggplot(iris, aes(Sepal.Length, Species))+geom_point(color="firebrick")+
+   theme(plot.background = element_rect(fill = 'pink'))

プロットの背景