View source: R/save_dye_screen_figs.R
convert_heights | R Documentation |
save_stacked_plots()
function.This is a brute-force way of getting around challenges of autoamtically determining the height of a full ggplot object. While we can set the panel heights precisely, I haven't figured out a good way to set all additional obejct sizes to allow perfect computation of output plot height (e.g. axis text, axis ticks, margins...). This is a simple arithmetic operation, but i pulled it into a helper function to allow more robust tuning of this converstion, and to simplify the code for the functions which use it.
convert_heights(
.paneled_by,
.raw_panel_height = 0.4,
facet_type = "wrap",
.ncol_wide = 10,
.wrap_margin_ratio = 190/110,
.grid_margin_ratio = 150/110,
.title_height_add = 0.3,
...
)
.paneled_by |
a list or vector containing the variable by which the plot was faceted. used only for it's length. |
.raw_panel_height |
the fored height of the panel. defaults to 0.4 |
facet_type |
the type of faceting applied to the plot, "wrap" or "grid", because this number is different for wraps anada grids. |
.ncol_wide |
the number of columns in the facet, used to calculate the number of rows in the facet. |
.wrap_margin_ratio |
a number, giving the ratio between the height of a full panel and the height of just it's forced plot area, for wrapped facets. Defaults to 190/110, but this may be a bit too large for standard applications. |
.grid_margin_ratio |
a number, giving the ratio between the height of a full panel and the height of just it's forced plot area, for grid facets. Defaults to 190/110, but this may be a bit too large for standard applications. |
.title_height_add |
a number, giving a constant amount to add to each plot to accomodate single-appearance items like titles and legends. |
... |
additional arguments, passed from upstream functions. Passed to nothing; places here to enable the passing of named arguments in this function using ... from upstream functions, which ignoring arguments passed in the same ... which do not match anything here. |
Note that there is at least one function get_dims from the package infotroph/DeLuciatoR, which does this calculation, but function relied on unstable side effects of certain functions. I didn't use it, because I don't want to take a dependency on something like that.
a number, giving the estimated height of a faceted plot created based on the variable defined in paneled-by
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.