Aan de slagGa gratis aan de slag

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.)

Deze oefening maakt deel uit van de cursus

Visualizing Time Series Data in R

Cursus bekijken

Oefeninstructies

  • 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

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

# Plot the second time series and change title


# Replot with same title, add subtitle, use bars


# Change line color to red
Code bewerken en uitvoeren