
- ggplot2 教程
- ggplot2 - 主頁
- ggplot2 - 簡介
- ggplot2 - 安裝 R
- ggplot2 - R 中的預設繪圖
- ggplot2 - 操作座標軸
- ggplot2 - 操作圖例
- ggplot2 - 散點圖和抖動圖
- ggplot2 - 條形圖和直方圖
- ggplot2 - 餅圖
- ggplot2 - 邊緣圖
- ggplot2 - 氣泡圖和計數圖
- ggplot2 - 發散圖
- ggplot2 - 主題
- ggplot2 - 多面板繪圖
- ggplot2 - 多個繪圖
- ggplot2 - 背景顏色
- ggplot2 - 時間序列
- ggplot2 實用資源
- ggplot2 - 快速指南
- ggplot2 - 實用資源
- ggplot2 - 討論
ggplot2 - 主題
在本章中,我們將重點介紹使用自定義主題,該主題用於更改工作區的觀感。我們將使用“ggthemes”包來理解 R 工作區中的主題管理概念。
讓我們執行以下步驟,在提到的資料集中使用所需的主題。
GGTHEMES
在 R 工作區中使用所需的包安裝“ggthemes”包。
> install.packages("ggthemes") > Library(ggthemes)

實施新主題來生成製造商圖例及其生產年份和排量。
> library(ggthemes) > ggplot(mpg, aes(year, displ, color=factor(manufacturer)))+ + geom_point()+ggtitle("This plot looks a lot different from the default")+ + theme_economist()+scale_colour_economist()

可以觀察到,使用以前的主題管理後,刻度線、圖例和其他元素的預設大小都比較小。輕鬆更改所有文字元素的大小。這可以透過建立一個自定義主題來實現,在以下步驟中可以看到,所有元素的大小都與 base_size 相對 (rel())。
> theme_set(theme_gray(base_size = 30)) > ggplot(mpg, aes(x=year, y=class))+geom_point(color="red")

廣告