---
# System prepended metadata

title: 基礎繪圖
tags: [R教學, 基礎教學]

---

# 基礎繪圖
###### tags: `R教學` `基礎教學`

**參考網站：**[Quick R](https://www.statmethods.net/graphs/density.html
)

```r=
mtcars$wt

#頻率分布圖 (Histograms)
hist(mtcars$wt)
hist(rnorm(10000,0,1))

# 盒鬚圖 (Boxplots)
boxplot(mtcars$wt, mtcars$mpg)

#圓點圖 (Dot plots)
dotchart(mtcars$wt, 
         labels = row.names(mtcars))
dotchart(mtcars$am, 
         labels = row.names(mtcars))

#直方圖 (Bar plots)
barplot(mtcars$wt)

#圓餅圖 (Pie charts)
pie(c(10,5,3,1))

#折線圖 (Line charts)
#散佈圖 (Scatterplots)
plot(mtcars$wt, mtcars$mpg)

plot(mtcars$wt, mtcars$mpg, type = "o")
dat <- mtcars[order(mtcars$wt),c("wt", "mpg")]
plot(dat$wt, dat$mpg, type="o")
```