ProjectMOSAIC / ggformula

Provides a formula interface to 'ggplot2' graphics.
Other
38 stars 11 forks source link

applying a theme #157

Closed nicholasjhorton closed 1 year ago

nicholasjhorton commented 1 year ago

Do you have any guidance about what I'm doing wrong here? I was hoping to move to a black and white theme with this plot:

library(ggformula)
#> Loading required package: ggplot2
#> Loading required package: ggstance
#> 
#> Attaching package: 'ggstance'
#> The following objects are masked from 'package:ggplot2':
#> 
#>     geom_errorbarh, GeomErrorbarh
#> Loading required package: scales
#> Loading required package: ggridges
#> 
#> New to ggformula?  Try the tutorials: 
#>  learnr::run_tutorial("introduction", package = "ggformula")
#>  learnr::run_tutorial("refining", package = "ggformula")
gf_point(pcs ~ age, color = ~ homeless, data = mosaicData::HELPrct) |>
  gf_theme(theme_bw())

Created on 2023-02-08 with reprex v2.0.2

rpruim commented 1 year ago

You do have a black and white theme (theme_bw()), but the theme in ggplot2 doesn't handle the colors of the data. It's the scales that do that job. The theme covers things like the axes, title, other labeling, etc.

So it is a bit confusing, I guess. But this is doing what ggplot2 says it should do.

rpruim commented 1 year ago

Here's an example of using a grey-scale color scale:

suppressPackageStartupMessages(library(ggformula))
gf_point(pcs ~ age, color = ~ homeless, data = mosaicData::HELPrct) |>
  gf_theme(theme_bw()) |>
  gf_refine(scale_color_grey())

You could also use scale_color_manual() and select your own colors.

Created on 2023-02-18 with reprex v2.0.2