Skip to content

Can i recover the aesthetic mapping from within a compute_*() step? #68

Answered by teunbrand
corybrunson asked this question in Q&A
Discussion options

You must be logged in to vote

A variant of the approach above is that you ggproto_parent(old_layer, self)$compute_statistic() after you've copied the computed mapping. Then you'd be unaffected by changes that ggplot2 would make in Layer$compute_statistic().

Another approach could be to append an extra class to your layer, and use a custom ggplot_add() method that sort of mirrors Layer$setup_data() to combine global and local mappings, and pass that on as a layer parameter. This is 'sanctioned' to some degree, but a more roundabout way to getting to the same state.

Replies: 2 comments 10 replies

Comment options

You must be logged in to vote
8 replies
@teunbrand
Comment options

@corybrunson
Comment options

@teunbrand
Comment options

@teunbrand
Comment options

Answer selected by corybrunson
@yjunechoe
Comment options

@corybrunson
Comment options

@teunbrand
Comment options

Comment options

You must be logged in to vote
2 replies
@corybrunson
Comment options

@EvaMaeRey
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants