|
6 | 6 | package frontendContextDemo.scripts
|
7 | 7 |
|
8 | 8 | import frontendContextDemo.ScriptInBatikContext
|
9 |
| -import org.jetbrains.letsPlot.GGBunch |
10 | 9 | import org.jetbrains.letsPlot.geom.geomBoxplot
|
11 | 10 | import org.jetbrains.letsPlot.geom.geomDensity
|
12 |
| -import org.jetbrains.letsPlot.ggsize |
| 11 | +import org.jetbrains.letsPlot.ggbunch |
13 | 12 | import org.jetbrains.letsPlot.letsPlot
|
| 13 | +import org.jetbrains.letsPlot.themes.elementRect |
| 14 | +import org.jetbrains.letsPlot.themes.theme |
| 15 | +import org.jetbrains.letsPlot.themes.themeBW |
14 | 16 | import kotlin.math.abs
|
15 | 17 |
|
16 | 18 | object GGBunchDemo {
|
17 | 19 | @JvmStatic
|
18 | 20 | fun main(args: Array<String>) {
|
19 | 21 | ScriptInBatikContext.eval(
|
20 |
| - "GGBunch: Density + Boxplot", |
| 22 | + "ggbunch(): Density + Boxplot", |
21 | 23 | maxCol = 2
|
22 | 24 | ) {
|
23 |
| - val density = letsPlot(densityData()) + geomDensity(color = "red", alpha = 0.3, size = 5.0) { x = "x" } |
24 |
| - val boxplot = letsPlot(boxplotData()) { x = "cat"; y = "val" } + geomBoxplot(outlierColor = "red") |
| 25 | + val theme = themeBW() + theme(plotBackground = elementRect(size = 1)) |
| 26 | + val density = letsPlot(densityData()) + |
| 27 | + geomDensity(color = "red", alpha = 0.3, size = 5.0) { x = "x" } + theme |
| 28 | + val boxplot = letsPlot(boxplotData()) { x = "cat"; y = "val" } + |
| 29 | + geomBoxplot(outlierColor = "red") + theme |
25 | 30 |
|
26 |
| - // set plot size via `addPlot` func param |
27 |
| - val w = 300 |
28 |
| - val h = 250 |
29 |
| - var bunch = GGBunch() |
30 |
| - bunch.addPlot(density, 0, 0, w, h) |
31 |
| - bunch.addPlot(boxplot, w + 10, h + 10, w, h) |
32 |
| - bunch.show() |
| 31 | + // Plots in opposite corners |
| 32 | + ggbunch( |
| 33 | + listOf(density, boxplot), |
| 34 | + regions = listOf( |
| 35 | + listOf(0, 0, 0.49, 0.49), |
| 36 | + listOf(0.51, 0.51, 0.49, 0.49), |
| 37 | + ) |
| 38 | + ).show() |
33 | 39 |
|
34 |
| - // set plot size via `ggsize` |
35 |
| - bunch = GGBunch() |
36 |
| - bunch.addPlot(density + ggsize(w, h), 0, 0) |
37 |
| - bunch.addPlot(boxplot + ggsize(w, h), w + 10, h + 10) |
38 |
| - bunch.show() |
39 |
| - |
40 |
| - // default plot sizes |
41 |
| - bunch = GGBunch() |
42 |
| - bunch.addPlot(density, 0, 0) |
43 |
| - bunch.addPlot(boxplot, w + 10, h + 10) |
44 |
| - bunch.show() |
| 40 | + // Overlapped plots |
| 41 | + ggbunch( |
| 42 | + listOf(density, boxplot), |
| 43 | + regions = listOf( |
| 44 | + listOf(0, 0, 0.6, 0.6), |
| 45 | + listOf(0.4, 0.4, 0.6, 0.6), |
| 46 | + ) |
| 47 | + ).show() |
45 | 48 | }
|
46 | 49 | }
|
47 | 50 |
|
|
0 commit comments