Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
@tjmahr I'm not sure this is the best way to offer this option, so if you have a better idea I'm definitely open to it. This PR adds functions
facet_relabel_gg()
andfacet_vars()
. These are intended to help users change facet labels. This is related to #75 and #157, although those issues relate mostly to changing legend labels, for which we will need some other option. This PR just addresses changing facet labels. (This wasn't much work so we can scrap it if it seems just like it's adding unnecessary bloat, since I suppose we could just tell people they need to use the factor labels they want used as facet labels and we won't provide a way to change them after the fact.)Example
From the proposed new doc:
facet_relabel_gg
is atypical in that it accepts a ggplot object as input (so it can detect the variable currently used for faceting) and returns a modified version of the same ggplot object as its output (with update facet labels). The...
can be use withfacet_relabel_gg
to manually pass other arguments to facet_wrap or facet_grid other than "facets" and "scales" arguments, which are automatically inferred from the plot object.facet_vars
takes a ggplot object as input and returns a character vector indicating the name of the variable(s) bayesplot uses internally to create facets (if any). Iffacet_relabel_gg
isn't flexible enough to relabel the facets how you want thenfacet_vars
gives you the info you need to addfacet_wrap
(orfacet_grid
) to the object yourself. The "scales" attribute of the facet_vars result indicates the value bayesplot used for the scales argument to facet_wrap (or facet_grid).