preliminary data initialization

library(tidyverse)
diamonds.small <-  diamonds[sample(nrow(diamonds), 500), ]
q <- ggplot(diamonds.small,aes(x=price, y=carat))

graph 1

A standard scatterplot of carat vs. price

q + geom_point() #scatter plot

graph 2

A scatter plot of carat vs. price in which the size of the points is proportional to the frequency (sometimes called a bubble plot)

q + geom_count(aes(size=..prop..),alpha=.5) #bubble plot

graph 3

A scatter plot of carat vs. price in which the size of the points is proportional to the relative frequency and the color is determined by the quality of the cut

q + geom_count(aes(size=..prop.., color=as.factor(cut)),alpha=.5) #bubble plot

graph 4

A jittered scatter plot of carat versus price overlaid with the least squares regression line for predicting price based on carat. Include the 95% confidence bands around the line.

q + geom_jitter()+ geom_smooth(method="lm",se=T,level=.95)

graph 5

A jittered scatter plot of carat versus price in which the cut quality is mapped to some aesthetic, overlaid with separate least squares regression lines for predicting price based on carat for each cut quality. Include the 67% confidence bands around the lines.

g <- ggplot(diamonds.small,aes(x=price, y=carat))
g + geom_jitter() + geom_smooth(method="lm",se=T,level=.67)

graph 6

Repeat of graph (5), but this time with polynomial regression instead of simple linear. I chose the polynomial degree gave the best fit with the smallest possible degree.

g <- ggplot(diamonds.small,aes(x=carat, y=price,color=as.factor(cut)))
g + geom_jitter() + geom_smooth(method="lm",se=T,level=.67,formula=y~poly(x,3))