Get startedGet started for free

plot() function - basic parameters (2)

You can add even more customization with the plot() function using other options. As you saw in the video, the lines() function is especially helpful when you want to modify an existing plot.

Let's look at another example:

> # Use bars instead of points and add subtitle
> plot(mydata, type = "h", sub = "Subtitle")

> # Triple thickness of line and change color to red
> lines(mydata, col = "red", lwd = 3)

In this exercise, you will try some of this customization for yourself. The same dataset, data, is available in your workspace. (If you can't remember the names of the columns, run colnames(data) in your console.)

This exercise is part of the course

Visualizing Time Series Data in R

View Course

Exercise instructions

  • Plot the second time series in data and change the title of the chart to "microsoft"
  • Replot with same title, include subtitle "Daily closing price since 2015", and use bars instead of points for the chart type
  • Change the color of the line to red without creating a new plot

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Plot the second time series and change title


# Replot with same title, add subtitle, use bars


# Change line color to red
Edit and Run Code