ggplot2推薦圖形配置
LHB阿好伯, 2020/12/17
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
ggplot2繪製的圖形非常漂亮
但若是要應用在正式一點的報告中還是會建議進行微調
今天就來分享幾個我喜歡的配置
純屬個人喜好沒有絕對的優劣
首先先安裝與載入這次會介紹的套件
theme主題設定
ggplot2預設是淡灰色背景
ggplot2內建theme_XXX系列函數可以用於修改主題
默認theme_gray()
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
可用主題theme_XXX()
主題名稱 |
特點 |
theme_gray |
帶有灰色背景和白色網格線的ggplot2主題 |
theme_bw |
經典的ggplot2主題,對於使用投影機顯示的文件可能會更好呈現 |
theme_linedraw |
僅在白色背景上具有各種寬度的黑色線條的主,具有類似的目的theme_bw。請注意,此主題有一些很細的線(<< 1 pt),有些期刊可能會拒絕。 |
theme_light |
類似於theme_linedraw但具有淺灰色線條和軸的主題,用於將更多的注意力引向數據。 |
theme_dark |
theme_light的黑色表親,具有相似的線條,但背景較暗。有助於使彩色細線突出。 |
theme_minimal |
沒有背景的簡約主題 |
theme_classic |
具有x和y軸線且無網格線的經典外觀主題 |
theme_void |
一個完全空的主題 |
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
|
|
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
|
|
可以添加theme_bw()或是theme_light()修改主題
theme_bw()或theme_light()個人覺得比較適合做為論文使用
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
圖形配色
修改完主題再來介紹一個配色的套件 ggsci
ggsci提供了一組ggplot2受科學期刊,數據可視化,科幻電影和電視節目啟發的調色板
其中非常喜歡她其中的UCSCGB配色
使用方式也十分簡單只需要加上scale_color_ucscgb()
或scale_fill_ucscgb()
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
更改字體配置
若是無法安裝可以改用showtext套件
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
匯入字體時發生 had status 139 : No FontName. Skipping.
在Ubuntu中匯入時發生錯誤後來發現是新版Rttf2pt1的錯誤
只需要重新安裝舊版即可
更改字體大小 - ggeasy
最後看到XY軸的字體有點小
這邊可以使用ggeasy的套件進行修改

到這邊大致上就是我會對ggplot2圖片的修改
更類似於我會在Sigmaplot所畫的圖片
最後總結一個今天使用到的程式碼
更改R的預設語系
有時候會發現ggplot2時間的輸出會是使用中文
然而可以修改系統語系更改輸出


🌟全文可以至下方連結觀看或是補充
全文分享至
https://www.facebook.com/LHB0222/
https://www.instagram.com/ahb0222/
有疑問想討論的都歡迎於下方留言
喜歡的幫我分享給所有的朋友 \o/
有所錯誤歡迎指教
