##############################################
#  More on data visualization in R
##############################################

plot(AGEPH ~ POWER, data = mtpl_tidy[1:1000, ],
     pch = 12, col = "blue", xlim = c(10, 150),
     main = 'Basic scatterplot')

## --------------------------------------------------------------------------------------------------------------------------------------------------
curve(dnorm, from = -5, to = 5,
      col = "red", lwd = 3, 
      main = "Standard normal density distribution")

## --------------------------------------------------------------------------------------------------------------------------------------------------
library(ggplot2)
ggplot(data = mtpl_tidy)

## --------------------------------------------------------------------------------------------------------------------------------------------------
ggplot(data = mtpl_tidy[1:1000, ]) + geom_point(mapping = aes(x = POWER, y = AGEPH))

## --------------------------------------------------------------------------------------------------------------------------------------------------
ggplot(data = mtpl_tidy[1:1000, ]) +
  geom_point(mapping = aes(x = POWER, y = AGEPH),
             color = "blue")

## --------------------------------------------------------------------------------------------------------------------------------------------------
ggplot(data = mtpl_tidy[1:1000, ]) +
  geom_point(mapping = aes(x = POWER, y = AGEPH,
                           color = SEX))

## --------------------------------------------------------------------------------------------------------------------------------------------------
ggplot(data = mtpl_tidy[1:1000, ]) +
  geom_point(mapping = aes(x = POWER, y = AGEPH)) +
  geom_smooth(mapping = aes(x = POWER, y = AGEPH))

## --------------------------------------------------------------------------------------------------------------------------------------------------
ggplot(data = mtpl_tidy[1:1000, ],
       mapping = aes(x = POWER, y = AGEPH)) +
  geom_point() + geom_smooth()

## --------------------------------------------------------------------------------------------------------------------------------------------------
ggplot(data = mtpl_tidy[1:1000, ],
       mapping = aes(x = POWER, y = AGEPH)) +
  geom_point(aes(color = SEX)) + 
  geom_smooth(color = 'purple') +
  labs(x = 'vehicle power',
       y = 'policyholder age') +
  ggtitle('Colorful scatterplot') +
  theme_bw()


## Your Turn!
## --------------------------------------------------------------------------------------------------------------------------------------------------




## --------------------------------------------------------------------------------------------------------------------------------------------------

