<jupyter_start><jupyter_text>GGBunch*GGBunch* allows to show a collection of plots on one figure. Each plot in the collection can have arbitrary location and size. There is no automatic layout inside the bunch.<jupyter_code>%useLatestDescriptors
%use lets-plot

@file:DependsOn("org.apache.commons:commons-math3:3.6.1")
import kotlin.random.Random
import org.apache.commons.math3.distribution.MultivariateNormalDistribution
val cov : Array<DoubleArray> = arrayOf(doubleArrayOf(1.0, 0.0),
                                        doubleArrayOf(0.0, 1.0))
val means : DoubleArray = doubleArrayOf(0.0, 0.0)
val xy = MultivariateNormalDistribution(means, cov).sample(400)

val xs = xy.map { it[0] }
val ys = xy.map { it[1] }<jupyter_output><empty_output><jupyter_text>View this data as a scatter plot and as a histogram<jupyter_code>val p = letsPlot() + ggsize(600,200)

val scatter = p + geomPoint(color="black", alpha=.4) {x=xs; y=ys}
scatter
val histogram = p + geomHistogram(fill="dark_magenta") {x=xs}
histogram<jupyter_output><empty_output><jupyter_text>Combine both plots in one figure<jupyter_code>// Set scale X limits manually because of computed automatically
// the scale used by each plot would be slightly different
// and the stacked plots wouldn't be aligned.
val scale_x = scaleXContinuous(limits=-3.5 to 3.5)
GGBunch().addPlot(histogram + scale_x, 0, 0)
         .addPlot(scatter + scale_x, 0, 200)<jupyter_output><empty_output><jupyter_text>Adjust visuals of the bunch figure<jupyter_code>val upper_theme = theme(axis="blank", axisText=elementText(), axisTitleY=elementText(), panelGridMajorY="blank")
val lower_theme = theme(axis="blank", axisTextY=elementText(), axisTitle=elementText())
GGBunch().addPlot(histogram + upper_theme + scale_x, 0, 0)
         .addPlot(scatter + lower_theme + scale_x, 0, 200)<jupyter_output><empty_output><jupyter_text>Adjust plot sizes*addPlot()* method has two more (optional) parameters: *width* and *height*.This values will override plot size earlier defined via *ggsize()* function.<jupyter_code>GGBunch().addPlot(histogram + upper_theme + scale_x, 0, 0, 600, 100)
         .addPlot(scatter + lower_theme + scale_x, 0, 100, 600, 300)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11693002257336343, 'fraction_numerical': 0.028442437923250564, 'mean_word_length': 5.57566765578635, 'pattern_counts': {'":': 0, '<': 22, '<?xml version=': 0, '>': 22, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '114910', 'license': 'MIT', 'n_tokens_mistral': 794, 'n_tokens_neox': 725, 'n_words': 192, 'path': 'docs/examples/jupyter-notebooks/ggbunch.ipynb', 'repo_name': 'isabella232/lets-plot-kotlin', 'size': '2215'}