jayqi / spongebob

SPoNgeBOb-CAse cONveRSioN ToOLs
https://jayqi.github.io/spongebob/
27 stars 3 forks source link

tospongebob.ggplot doesn't preserve groups with `fill`, `color`, etc. #22

Closed wdearden closed 5 years ago

wdearden commented 5 years ago
library(tvthemes)
library(magrittr)
library(ggplot2)
library(spongebob)

spongebob_plot <- mpg %>%
    ggplot(aes(displ, fill = class)) +
    geom_histogram(col = "black", size = 0.1) +
    labs(
        title = "F is for Fire that burns down the whole town!"
        , subtitle = "U is for Uranium... bombs! N is for No survivors when you're-"
        , caption = "Plankton, those things aren't what fun is about!"
    ) +
    theme_spongeBob(
        title.font = "Some Time Later"
        , text.font = "Some Time Later"
        , title.size = 22
        , subtitle.size = 16
        , axis.title.size = 16
        , axis.text.size = 14
        , legend.title.size = 14
    ) +
    scale_fill_spongeBob()

spongebob_plot2 <- tospongebob(spongebob_plot)

tospongebob(spongebob_plot) gives the following warning

`stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
Warning message:
This manual palette can handle a maximum of 9 values. You have supplied 150. 

The issue is the same string can get recoded in many different ways. The easiest solution which avoids digging into ggplot details would be to add an option to tospongebob.character to map identical strings in a vector in the same way. I will fix this issue.

wdearden commented 5 years ago

spongebob_plot image spongebob_plot2 image