LoslegenKostenlos loslegen

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

Diese Übung ist Teil des Kurses

Visualizing Time Series Data in R

Kurs anzeigen

Anleitung zur Übung

  • 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

Interaktive Übung

Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.

# Plot the second time series and change title


# Replot with same title, add subtitle, use bars


# Change line color to red
Code bearbeiten und ausführen