ImperialCollegeLondon / epidemia

epidemia package
https://imperialcollegelondon.github.io/epidemia/index.html
47 stars 15 forks source link

plot_rt() gives an empty plot #48

Closed wwiecek closed 4 years ago

wwiecek commented 4 years ago

When running plot_rt() for any model that I tried (including some of the built-in examples) I get a blank plot, like so:

image

This happens on Ubuntu 20.04 with R 4.0.2 and ggplot 3.3.2, but I also got the same with other machines (Windows, older R versions) so I assume it's more likely a problem with code.

Inspecting the plot object x I can see that x$layers has a ribbon part specified like this

[[1]]
mapping: ymin = ~lower, ymax = ~upper, group = ~tag, fill = ~tag, x = ~date 
geom_ribbon: na.rm = FALSE, orientation = NA, outline.type = both, flipped_aes = FALSE
stat_identity: na.rm = FALSE
position_identity 

But the input data x$data is:

> x$data
          date     lower     upper    group  tag level
1   2020-03-04 2.5626616 2.5927967 New York <NA>    20
2   2020-03-05 2.5626616 2.5927967 New York <NA>    20
3   2020-03-06 2.5626616 2.5927967 New York <NA>    20
4   2020-03-07 2.5626616 2.5927967 New York <NA>    20
5   2020-03-08 2.5626616 2.5927967 New York <NA>    20
6   2020-03-09 2.5626616 2.5927967 New York <NA>    20

So tag column will not play nice. If you map x$data$level to tag column, you can get it to work, sort of, giving the correct ribbon (but wrong alpha).

Perhaps I am doing something wrong when specifying the models?

wwiecek commented 4 years ago

Edit: pulling the recent commits seems to have helped with this.