# A tibble: 42 × 3
date type price
<date> <chr> <dbl>
1 2014-01-31 open 1791.
2 2014-01-31 close 1783.
3 2014-01-30 open 1777.
4 2014-01-30 close 1794.
5 2014-01-29 open 1790.
6 2014-01-29 close 1774.
7 2014-01-28 open 1783
8 2014-01-28 close 1792.
9 2014-01-27 open 1791.
10 2014-01-27 close 1782.
# ℹ 32 more rows
绘制折线图
基本折线图
sp500_data %>%ggplot(mapping =aes(x = date, y = price, color = type)) +geom_line(linewidth =1.25)
使用主题
sp500_data %>%ggplot(mapping =aes(x = date, y = price, color = type)) +geom_line(linewidth =1.25) +theme_minimal(base_size =20 ) +theme(panel.grid.minor =element_blank() )