davidhodge931 / ggblanket

Simplify ggplot2 visualisation
https://davidhodge931.github.io/ggblanket/
Other
156 stars 8 forks source link

class: how to determine classes #874

Closed davidhodge931 closed 5 months ago

davidhodge931 commented 5 months ago

Option 1: 1). determine classes based on x/y/col variables 2). determine if flipped 4). process the data 5). get_plot_base using processed data (Note won't work where mapping arg is used for y or col)

Option 2: 1). get_plot_base using raw data 2). determine classes based on scales. Note add criterion for colour & time 3). determine if flipped based on 2). 4). process the data 5). get_plot_base using processed data (Note won't work where mapping arg is used for y or col)

More flexible, as should still 'work' when everything is added to mapped arg More accurate at identified flipped-ness More simple code More slow, as building plot twice

Implications for

library(tidyverse)
library(ggblanket)
# library
set_blanket()

diamonds |>
    count(color) |>
    gg_col(
        x = n,
        # y = color,
        mapping = aes(y = fct_rev(color)),
        # mapping = aes(y = fct_reorder(color, n)),
        width = 0.75,
        x_labels = \(x) x / 1000,
        x_label = "Count (thousands)", 
        subtitle = "\nDefault order"
    )