hafen / trelliscopejs

TrelliscopeJS R Package
https://hafen.github.io/trelliscopejs
Other
262 stars 36 forks source link

facet_trelliscope empty plot; scale_y_continuous(trans = "log2") #107

Open dereckmezquita opened 3 years ago

dereckmezquita commented 3 years ago

Cannot use the scale_y_continuous(trans = "log2") option together with facet_trelliscope(). In fact no options from scale_y_continuous() work.

The data disappears I get blank plots when using this option in trelliscope.

I get this error:

using data from the first layer
Scale for 'y' is already present. Adding another scale for 'y', which will replace the existing scale.
Scale for 'y' is already present. Adding another scale for 'y', which will replace the existing scale.

Am I doing something wrong? Here is a minimal example with some toy data. Note: run as a chunk:

library("tidyverse")
library("trelliscopejs")

{read.delim(text = 
'year   country population  code    region
1800    "Afghanistan"   298000  "AFG"   "Southern Asia"
1801    "Afghanistan"   299000  "AFG"   "Southern Asia"
1802    "Afghanistan"   1100000 "AFG"   "Southern Asia"
1803    "Afghanistan"   3180000 "AFG"   "Southern Asia"
1804    "Afghanistan"   3280000 "AFG"   "Southern Asia"
1800    "Zimbabwe"  309000  "ZWE"   "Eastern Africa"
1801    "Zimbabwe"  309000  "ZWE"   "Eastern Africa"
1803    "Zimbabwe"  1100000 "ZWE"   "Eastern Africa"
1804    "Zimbabwe"  3100000 "ZWE"   "Eastern Africa"')} %>%
    ggplot(aes(year, population, group = country)) +
    geom_line() +
    scale_y_continuous(trans = "log2") +
    facet_trelliscope(~ region,
                    scales = "same",
                    name = "World population by region",
                    desc = "Population of each country by country and region",
                    nrow = 4, ncol = 4,
                    as_plotly = TRUE,
                    auto_cog = TRUE)

Screenshot 2021-02-08 at 22 03 44