I have merged two series to plot with ggplot2 but the second series plots as an area rather than a line. My input is a tibble which suggests something about the data. I have merged to xts series into a tibble, when I plot it, the first series shows as a line and the second shows as an area. I cannot understand why. The two series are similar in magnitude. The top of the red area is about right for the second series. Here is summary of the input data frame
> summary(us_cdn_xts)
Index us10y2y cdn10y2y
Min. :2004-01-01 Min. :-0.190 Min. :-0.1400
1st Qu.:2007-09-13 1st Qu.: 0.770 1st Qu.: 0.0000
Median :2011-05-26 Median : 1.460 Median : 0.6500
Mean :2011-05-26 Mean : 1.401 Mean : 0.6949
3rd Qu.:2015-02-05 3rd Qu.: 2.120 3rd Qu.: 1.2200
Max. :2018-10-18 Max. : 2.910 Max. : 2.3200
NA's :1700 NA's :159
>
Code is below
> plot_data<-tidy(us_cdn_xts)
> print(plot_data)
# A tibble: 10,810 x 3
index series value
<date> <chr> <dbl>
1 2004-01-01 us10y2y NA
2 2004-01-02 us10y2y 2.44
3 2004-01-03 us10y2y NA
4 2004-01-04 us10y2y NA
5 2004-01-05 us10y2y 2.46
6 2004-01-06 us10y2y 2.45
7 2004-01-07 us10y2y 2.43
8 2004-01-08 us10y2y 2.42
9 2004-01-09 us10y2y 2.43
10 2004-01-10 us10y2y NA
# ... with 10,800 more rows
> library(ggthemes)
> term_plot<-ggplot(plot_data,aes(x=index,y=value,colour=series))+
+ geom_line()
> ggsave(term_plot,file="term_plot.png")
Saving 7 x 7 in image
Warning message:
Removed 3 rows containing missing values (geom_path).
>