Chart::GGPlot::Facet - The facet class


version 0.0005


A "facet" object describes how to assign data to different panels, how to apply positional scales and how to layout the panels, once rendered.


render_axes($x, $y, $coord, $theme, $transpose=false)

Render panel axes.

Returns a hash ref with keys "x" and "y", each containing axis specifications for the ranges passed in. Each axis specification is a hash ref with a set of "top" and "bottom" or "left" and "right" keys, holding the respective axis grobs. If transpose is true the content of the x and y elements will be transposed.

render_strips($x, $y, $labeller, $theme)

Render panel strips.

Returns a hashref with keys "x" and "y", each is a hash ref containing a set of "top" and "bottom" or "left" and "right" keys respectively. These contains a hash ref of rendered strips as gtables.


compute_layout($data, $params)

Based on layer data compute a mapping between panels, axes, and potentially other parameters such as faceting variable level etc. This method must return a data.frame containing at least the columns "PANEL", "SCALE_X", and "SCALE_Y" each containing integer keys mapping a PANEL to which axes it should use. In addition the data frame can contain whatever other information is necessary to assign observations to the correct panel as well as determining the position of the panel.

map_data($data, $layout, $params)

This method is supplied the data for each layer in turn and is expected to supply a "PANEL" column mapping each row to a panel defined in the layout. Additionally this method can also add or subtract data points as needed e.g. in the case of adding margins to "facet_grid".


    init_scales($layout, $params, :$x_scales=undef, :$y_scales=undef)

Given a master scale for x and y, create panel specific scales for each panel defined in the layout. The default is to simply clone the master scale.


    train_scales($data, $layout, $params,
                 :$x_scales=undef, :$y_scales=undef)

Based on layer data train each set of panel scales. The default is to train it on the data related to the panel.


    finish_data($data, $layout, $params,
                :$x_scales, :$y_scales)

Make last-minute modifications to layer data before it is rendered by the Geoms. The default is to not modify it.


Stephan Loyd <>


This software is copyright (c) 2019 by Stephan Loyd.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.