You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-`facetWrap()` now drops factor levels that do not appear in the data (i.e., empty panels) by default [[#1322](https://github.com/JetBrains/lets-plot/issues/1322)]. <br>
* @param dpi Dot-per-Inch value to store in the exported file metadata (only for raster formats).
37
+
* @param w Width of the output image in units.
38
+
* @param h Height of the output image in units.
39
+
* @param unit Unit of the output image. One of: `"in"`, `"cm"`, `"mm"`, `"px"`.
40
+
* Only applicable when exporting to SVG, PNG, JPG, or TIFF.
41
+
* @param dpi Resolution in dots per inch to store in the exported file metadata.
42
+
* Only applicable when exporting to the raster formats: PNG, JPG, or TIFF.
37
43
* Default: no metadata is stored.
38
44
* @param path Path to a directory to save image files in.
39
45
* Default: `${user.dir}/lets-plot-images`
40
46
*
41
-
* @return Absolute pathname of created file.
47
+
* @return Absolute pathname of the created file.
48
+
*
49
+
* ### Notes
50
+
*
51
+
* The output format is inferred from the file extension.
52
+
*
53
+
* **For PNG and PDF:**
54
+
*
55
+
* - If [w], [h], [unit], and [dpi] are all specified:
56
+
*
57
+
* - The plot's pixel size (default or set via [ggsize()](https://lets-plot.org/kotlin/api-reference/-lets--plot--kotlin/org.jetbrains.letsPlot/ggsize.html) is ignored.
58
+
* - The output size is computed from the given dimensions and DPI.
59
+
* - The plot is resized to fit the specified [w] x [h] area, which may affect the layout.
60
+
*
61
+
* - If only [dpi] is specified:
62
+
* - The plot's pixel size (default or set via [ggsize()](https://lets-plot.org/kotlin/api-reference/-lets--plot--kotlin/org.jetbrains.letsPlot/ggsize.html)) is converted to inches assuming the standard display PPI of 96 PPI.
63
+
* - The output size is computed from this size and [dpi].
64
+
* - The plot maintains its aspect ratio, preserving layout, tick labels, and other visual elements.
65
+
* - Useful for printing - the plot will appear nearly the same size as on screen.
66
+
*
67
+
* - If [w] and [h] are not specified:
68
+
* - The [scale] parameter is used to determine the output size.
69
+
*
70
+
* - The plot maintains its aspect ratio, preserving layout, tick labels, and other visual elements.
71
+
* - Useful for generating high-resolution images suitable for publication.
72
+
*
73
+
* **For SVG:**
74
+
* - If [w], [h], and [unit] are specified:
75
+
* - The plot's pixel size (default or set via [ggsize()](https://lets-plot.org/kotlin/api-reference/-lets--plot--kotlin/org.jetbrains.letsPlot/ggsize.html)) is ignored.
76
+
* - The output size is set from the given values.
77
+
*
78
+
* **For HTML:**
79
+
* - If [w] and [h] are specified:
80
+
* - The plot's pixel size (default or set via [ggsize()](https://lets-plot.org/kotlin/api-reference/-lets--plot--kotlin/org.jetbrains.letsPlot/ggsize.html)) is ignored.
81
+
* - The output size is determined directly from the specified [w] and [h], which are treated as pixel values.
82
+
*
42
83
*/
43
84
@Suppress("SpellCheckingInspection")
44
85
funggsave(
45
86
plot:Figure,
46
87
filename:String,
47
-
scale:Number = 2,
88
+
scale:Number? = null,
89
+
w:Number? = null,
90
+
h:Number? = null,
91
+
unit:String? = null,
48
92
dpi:Number? = null,
49
93
path:String? = null
50
94
): String {
@@ -65,10 +109,16 @@ fun ggsave(
65
109
val file = dir.resolve(filename)
66
110
67
111
val spec:MutableMap<String, Any> = plot.toSpec()
112
+
val sizeUnit =PlotExportCommon.SizeUnit.fromName(unit ?:"")
113
+
val plotSize = toDoubleVector(w, h)
68
114
69
115
when (ext) {
70
116
"svg"-> {
71
-
val svg =PlotSvgExport.buildSvgImageFromRawSpecs(spec)
0 commit comments