Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pagination of large facet plots #303

Closed
MichaelHatherly opened this issue Oct 27, 2021 · 4 comments
Closed

Pagination of large facet plots #303

MichaelHatherly opened this issue Oct 27, 2021 · 4 comments

Comments

@MichaelHatherly
Copy link
Contributor

When faceting a plot over a large number of columns/rows (or just wrapping with layout) the size of the plots can sometimes become quite unwieldy and requires manual intervention to increase the figure size or shrink the font size. Something that's a nice feature to have is pagination of faceted plots to reduce the amount of of axes that appear per-figure. There's a couple of options to do this with ggplot2: ggforce and gridExtra can handle this.

The basic look of the API is instead of writing this:

layer = data(df) * mapping(:id, :wt; layout = :dose => nonnumeric)
draw(layer)

image

we wrap the Layer with paginate:

draw(
	paginate(
		layer;
		limit = 4
	)
)

image

which just partitions the .data contained in the Layer based on what's used in layout (or row and col).

If there's interest in upstreaming this I'm happy to sort that out. Pagination has come in handy for a lot of our plotting needs in Pumas so I figured it may be more generally useful.

@piever
Copy link
Collaborator

piever commented Oct 28, 2021

Thanks, this looks very useful, it definitely would be great to upstream the feature to AoG.

About the API, draw now has a facet keyword argument to pass keywords specific to facet plots (see eg here), so maybe this could also be set there as a facet option.

OTOH, the current facet options tends to be things that are done directly via MakieLayout (the keywords are simply forwarded to facet!, which runs some Makie functions to improve the looks of a facet plot), so maybe it makes more sense that it is done wrapping the layer object.

@MichaelHatherly
Copy link
Contributor Author

MichaelHatherly commented Oct 28, 2021

About the API, draw now has a facet keyword argument to pass keywords specific to facet plots (see eg here), so maybe this could also be set there as a facet option.

I considered that approach, the main issue I ran into with that approach, i.e.

draw(layers; facet = (; paginate = true,)) # or something like that..

is that the return type changes from FigureGrid to Vector{FigureGrid} by changing a keyword, which doesn't feel very nice. By operating on the Layer instead you can change the input argument type to something else (a Paginate object in the current iteration) which then dispatches to a different draw implementation which felt a bit better from an API point-of-view. It still feels a bit too close to some kind of "implicit broadcasting" behaviour and might be interesting to see whether a broadcasted draw might work

draw.(layers; kws...)

or just wrap it all in a separate paginate function instead of draw where

draw(
	paginate(
		layers;
		limit = 4
	)
)

would just become

paginate(layers; kws...)

though that does end up forcing the keywords associated with paginate into the same call as those for draw.

(Edit: the added benefit of just processing the Layer input is that the implementation of this doesn't end of needing to change any of the current internals of AoG, which was a nice added bonus.)

@piever
Copy link
Collaborator

piever commented Oct 29, 2021

Ah, of course, I hadn't thought that the output type is different. Then it makes a lot of sense to wrap the input, I agree that the API proposed initially, ie draw(paginate(layers; limit); kwargs...), is the cleanest solution.

@jkrumbiegel jkrumbiegel mentioned this issue Jun 27, 2022
@jkrumbiegel
Copy link
Member

pagination has existed for a while now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants