google / CausalImpact

An R package for causal inference in time series
Apache License 2.0
1.71k stars 254 forks source link

CausalImpact plot function bug for ggplot2::geom_ribbon() #36

Closed MilaniC closed 4 years ago

MilaniC commented 4 years ago

R 3.6.1 CausalImpact version 1.2.3 ggplot2 version 3.2.1 MacOS 10.14.6

Recent updates to ggplot2 (mainly geom_ribbon()) breaks the plot function in CasualImpact. All works except no ribbon plotted (see attached PDF 1).

Fig 2 attached shows that geom_ribbon() works fine if I use my own ggplot2 code here from a Stan model output. So it is the internal plot function in CausalImpact that is no longer functioning with ggplot2.

I, and I am sure others, would be grateful for a fix for this plot bug.

Fig1.pdf Fig2.pdf

fmarquezg commented 4 years ago

not sure if this is related to the ggplot2 update. I went back to ggplot2 version 3.0.0 (2018-07-03) and still no luck

fmarquezg commented 4 years ago

[SOLVED] The issue is the color for the ribbon. It is currently set to 'SlateGray2', but R is now case sensitive, so it should be 'slategray2'. The rest of the colors in the plot file are lowercase, so geom_ribbon is the only affected part.

I submitted a pull request with the solution so hopefully Google can update it. If you don't want to wait feel free to use my forked version or update the name on your local machine.

(@MilaniC)

MilaniC commented 4 years ago

@fmarquezg much appreciated