Exercise 1: hist and Density Plot
The raw plot
x <- seq(-pi*2, 2*pi, .05)
z <- dnorm(x)
y <- dt(x, df=3)
plot(x, z, type="l", bty="L", xlab="Standard unit", ylab="Density")
polygon(c(x, rev(x)), c(y, rev(z)), col='aliceblue')
lines(x, y, col='cadetblue')

Change the ‘df’ parameter to a slightly larger integer
x <- seq(-pi*2, 2*pi, .05)
z <- dnorm(x)
y <- dt(x, df=5)
plot(x, z, type="l", bty="L", xlab="Standard unit", ylab="Density")
polygon(c(x, rev(x)), c(y, rev(z)), col='aliceblue')
lines(x, y, col='cadetblue')

Again, change the ‘df’ parameter to a slightly larger intege
x <- seq(-pi*2, 2*pi, .05)
z <- dnorm(x)
y <- dt(x, df=10)
plot(x, z, type="l", bty="L", xlab="Standard unit", ylab="Density")
polygon(c(x, rev(x)), c(y, rev(z)), col='aliceblue')
lines(x, y, col='cadetblue')

In my visual inspection of the three plots, I observed that the aliceblue color line progressively close the standard unit densitu function.
The results may related to dt function and when df increases, the normality also increases.
Exercise 2: Lung Cancer and Cigarettes Consumption
Load data file
## Country consumption death
## 1 Australia 480 180
## 2 Canada 500 150
## 3 Denmark 380 170
## 4 Finland 1100 350
## 5 UK 1100 460
## 6 Iceland 230 60
Prepare a plot enviornment, next add regression line between death rate and cigarettes consumption, then add on the label states.
with(dta, plot(consumption, death, type='n',
main='Lung Cancer and Cigarettes Consumption',
xlab='Consumption (per capita per year)',
ylab='Death rate (per million)'))
# add regression line
abline(lm(death ~ consumption, data=dta))
# label states
with(dta, text(consumption, death, labels=Country, cex=.5))

Exercise 3: National flag of Denmark
## $xlog
## [1] FALSE
##
## $ylog
## [1] FALSE
##
## $adj
## [1] 0.5
##
## $ann
## [1] TRUE
##
## $ask
## [1] FALSE
##
## $bg
## [1] "white"
##
## $bty
## [1] "o"
##
## $cex
## [1] 1
##
## $cex.axis
## [1] 1
##
## $cex.lab
## [1] 1
##
## $cex.main
## [1] 1.2
##
## $cex.sub
## [1] 1
##
## $cin
## [1] 0.15 0.20
##
## $col
## [1] "black"
##
## $col.axis
## [1] "black"
##
## $col.lab
## [1] "black"
##
## $col.main
## [1] "black"
##
## $col.sub
## [1] "black"
##
## $cra
## [1] 10.8 14.4
##
## $crt
## [1] 0
##
## $csi
## [1] 0.2
##
## $cxy
## [1] 0.02604167 0.06329114
##
## $din
## [1] 7 5
##
## $err
## [1] 0
##
## $family
## [1] ""
##
## $fg
## [1] "black"
##
## $fig
## [1] 0 1 0 1
##
## $fin
## [1] 7 5
##
## $font
## [1] 1
##
## $font.axis
## [1] 1
##
## $font.lab
## [1] 1
##
## $font.main
## [1] 2
##
## $font.sub
## [1] 1
##
## $lab
## [1] 5 5 7
##
## $las
## [1] 0
##
## $lend
## [1] "round"
##
## $lheight
## [1] 1
##
## $ljoin
## [1] "round"
##
## $lmitre
## [1] 10
##
## $lty
## [1] "solid"
##
## $lwd
## [1] 1
##
## $mai
## [1] 1.02 0.82 0.82 0.42
##
## $mar
## [1] 5.1 4.1 4.1 2.1
##
## $mex
## [1] 1
##
## $mfcol
## [1] 1 1
##
## $mfg
## [1] 1 1 1 1
##
## $mfrow
## [1] 1 1
##
## $mgp
## [1] 3 1 0
##
## $mkh
## [1] 0.001
##
## $new
## [1] FALSE
##
## $oma
## [1] 0 0 0 0
##
## $omd
## [1] 0 1 0 1
##
## $omi
## [1] 0 0 0 0
##
## $page
## [1] TRUE
##
## $pch
## [1] 1
##
## $pin
## [1] 5.76 3.16
##
## $plt
## [1] 0.1171429 0.9400000 0.2040000 0.8360000
##
## $ps
## [1] 12
##
## $pty
## [1] "m"
##
## $smo
## [1] 1
##
## $srt
## [1] 0
##
## $tck
## [1] NA
##
## $tcl
## [1] -0.5
##
## $usr
## [1] 0 1 0 1
##
## $xaxp
## [1] 0 1 5
##
## $xaxs
## [1] "r"
##
## $xaxt
## [1] "s"
##
## $xpd
## [1] FALSE
##
## $yaxp
## [1] 0 1 5
##
## $yaxs
## [1] "r"
##
## $yaxt
## [1] "s"
##
## $ylbias
## [1] 0.2
plot.new()
plot.window(xlim=c(0, 37), ylim=c(0, 28))
rect(xleft = 0, ybottom = 0, xright = 37, ytop = 28, col="red")
rect(12, 0, 16, 37, col="white", border="white")
rect(0, 12, 37, 16, col="white", border = "white")

Exercise 4:
create a sequence from 0 to 2pi, then, set x=sin(t), y=cos(t)
generates a square plotting
Exercise 5: Draw a pie chart to represent 50 shades of gray.
