library(pgmm)

data(coffee)

str(coffee)
## 'data.frame':    43 obs. of  14 variables:
##  $ Variety            : num  1 1 1 1 1 1 1 1 1 1 ...
##  $ Country            : Factor w/ 29 levels "angola","brasile",..: 19 19 12 15 24 24 24 21 20 7 ...
##  $ Water              : num  8.94 7.4 9.74 10.4 10.54 ...
##  $ Bean Weight        : num  157 157 153 174 145 ...
##  $ Extract Yield      : num  33.5 32.1 33.1 31.5 35.2 ...
##  $ ph Value           : num  5.8 5.81 5.26 5.61 5.77 5.83 5.62 5.89 5.75 5.82 ...
##  $ Free Acid          : num  32.7 30.8 36.7 34.2 31.8 ...
##  $ Mineral Content    : num  3.8 3.71 4.15 3.94 4.09 3.88 3.85 3.85 4.22 4.01 ...
##  $ Fat                : num  15.2 15 16.1 15.8 15.2 15.4 15.6 15.1 14.3 15.1 ...
##  $ Caffine            : num  1.13 1.25 1.21 1.06 1.11 1.2 1.33 1.28 1.16 1.32 ...
##  $ Trigonelline       : num  1.03 1.01 1.05 0.94 0.99 0.81 1.16 0.98 0.97 0.97 ...
##  $ Chlorogenic Acid   : num  5.38 5.13 5.94 5.87 5.09 5.3 4.8 4.96 5.53 5.12 ...
##  $ Neochlorogenic Acid: num  0.4 0.32 0.24 0.39 0.49 0.43 0.32 0.32 0.36 0.29 ...
##  $ Isochlorogenic Acid: num  0.79 0.97 0.76 0.59 0.72 0.69 0.74 0.66 0.8 0.69 ...
## boxplot on a formula:
boxplot(Fat ~ Variety, data = coffee, col = "lightgray")

boxplot(Fat ~ Variety, data = coffee, col = 2:3)

boxplot(Fat ~ Variety, data = coffee, col = rainbow(2))

boxplot(Caffine ~ Variety, data = coffee, col = c("red","yellow"))

plot(coffee$Fat, coffee$Caffine, xlab="Fat",ylab="Caffine", 
     col= coffee$Variety, palette = c("#00AFBB", "#E7B800"))
## Warning in plot.window(...): "palette" 不是一個繪圖參數
## Warning in plot.xy(xy, type, ...): "palette" 不是一個繪圖參數
## Warning in axis(side = side, at = at, labels = labels, ...): "palette" 不是一個
## 繪圖參數

## Warning in axis(side = side, at = at, labels = labels, ...): "palette" 不是一個
## 繪圖參數
## Warning in box(...): "palette" 不是一個繪圖參數
## Warning in title(...): "palette" 不是一個繪圖參數
library(ggpubr)
## 載入需要的套件:ggplot2
coffee$Variety <- factor(coffee$Variety, labels=c("Arabica","Robusta"))

ggscatterhist(
  coffee, x = "Caffine", y = "Fat",
  color = "Variety", size = 3, alpha = 0.6,
  palette = c("#00AFBB", "#E7B800"),
  margin.params = list(fill = "Variety", color = "black", size = 0.2)
)