Plot normal curve
Continue with the two stocks. The aim is to produce a single plot containing the two assumed normal curves. Start with plotting the normal curve for the return on Microsoft stock.
With plot(x, y)
, you can plot the values of y
on the y-axis against the
values of x
on the x-axis. You can customize the plot in many ways through
additional arguments
(see the documentation):
set type = "l"
to plot the data as a connected line, use col
to specify the
line color, set axis labels with xlab
and ylab
, or set axis limits with
xlim
and ylim
.
This exercise is part of the course
Intro to Computational Finance with R
Exercise instructions
- Plot a line for the values of the assumed normal density for the return on Microsoft stock (
MSFT
) againstx_vals
. - Customize the plot in the following way: use a blue line, set the y-axis label to
"Normal curves"
, and set the y-axis to be in the interval \([0,8]\).
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# MSFT and x_vals are still in your workspace
# Normal curve for MSFT