or
or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up
Syntax | Example | Reference | |
---|---|---|---|
# Header | Header | 基本排版 | |
- Unordered List |
|
||
1. Ordered List |
|
||
- [ ] Todo List |
|
||
> Blockquote | Blockquote |
||
**Bold font** | Bold font | ||
*Italics font* | Italics font | ||
~~Strikethrough~~ | |||
19^th^ | 19th | ||
H~2~O | H2O | ||
++Inserted text++ | Inserted text | ||
==Marked text== | Marked text | ||
[link text](https:// "title") | Link | ||
 | Image | ||
`Code` | Code |
在筆記中貼入程式碼 | |
```javascript var i = 0; ``` |
|
||
:smile: | ![]() |
Emoji list | |
{%youtube youtube_id %} | Externals | ||
$L^aT_eX$ | LaTeX | ||
:::info This is a alert area. ::: |
This is a alert area. |
On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?
Please give us some advice and help us improve HackMD.
Do you want to remove this version name and description?
Syncing
xxxxxxxxxx
ggplot2邊緣圖_ggExtra
tags:
R
ggplot2
可視化
今天來介紹ggplot2的邊緣圖的相關套件ggExtra

使用鳶尾花iris數據集來做範例
其數據集包含了150個樣本,都屬於鳶尾屬下的三個亞屬,分別是山鳶尾(setosa)、變色鳶尾(versicolor)和維吉尼亞鳶尾(virginica)分別包含了花萼和花瓣的長度和寬度資料
載入所需套件
基本圖形
首先先繪製最基本的散佈圖
使用ggExtra的ggMarginal函數繪製邊緣圖
預設是繪製密度圖

可以以添加變數
type = "histogram"
ortype = "boxplot"
ortype = "violin"
更改為直方圖、箱型圖或小提琴圖或是
type = "densigram"
可以繪製直方圖與密度圖的結合
邊緣圖美化
顏色修改
添加
groupColour = TRUE, groupFill = TRUE
變數可以使的邊緣圖與散佈圖有一樣的顏色額外參數
添加
xparams = list(bins=10), yparams = list(bins=10)
參數可以修改直方圖的組數更改圖例位置
我們可以將圖利更改為下方這樣就可以騰出位置給邊緣圖
更進一步我們也可以自訂圖例位置與外觀
🌟若是有興趣有可以到這下面的網站玩玩看

https://daattali.com/shiny/ggExtra-ggMarginal-demo/
🌟全文可以至下方連結觀看或是補充
全文分享至
https://www.facebook.com/LHB0222/
https://www.instagram.com/ahb0222/
有疑問想討論的都歡迎於下方留言
喜歡的幫我分享給所有的朋友 \o/
有所錯誤歡迎指教
- 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 →