ggtb(): sizeZoomin and sizeBasis Parameters for Geometry Scaling¶

sizeZoomin parameter¶

The sizeZoomin parameter accepts an integer value:

  • 0 — zoom in disabled (default)
  • -1 — unlimited zoom in
  • Any other positive number — maximum zoom-in limit. For example, 2 means the geometry can be scaled up to 2×.

sizeBasis parameter¶

The sizeBasis parameter accepts a string value: "x", "y", "min", or "max" (default: "max"). It defines which axis is used to calculate the scaling factor.

  • "x" and "y" specify the corresponding axis.
  • "min" uses the smaller scaling factor.
  • "max" uses the larger scaling factor.
In [1]:
%useLatestDescriptors
%use dataframe
%use lets-plot
In [2]:
LetsPlot.getInfo()
Out[2]:
Lets-Plot Kotlin API v.4.12.0. Frontend: Notebook with dynamically loaded JS. Lets-Plot JS v.4.8.1.
Outputs: Web (HTML+JS), Kotlin Notebook (Swing), Static SVG (hidden)

Enable 'Unlimited' Zoom¶

In [3]:
letsPlot() + geomPoint(x = 0, y = 0, size = 10) + ggtb(
    
    sizeZoomin = -1      // <-- Point size can grow without limits.
)
Out[3]:
-0.4 -0.2 0 0.2 0.4 -0.4 -0.2 0 0.2 0.4 y x

Limit Maximum Zoom to 3× Original Size¶

In [4]:
val df = DataFrame.readCSV("https://raw.githubusercontent.com/JetBrains/lets-plot-docs/master/data/mpg2.csv")
val mpg = df.toMap()
In [5]:
val p =
    letsPlot(mpg) {
        x = "engine horsepower"
        y = "miles per gallon"
        color = asDiscrete("origin of car", order = -1)
    } +
    themeGrey() +
    ggtitle("Efficiency vs Engine Horsepower")
In [6]:
p + geomJitter(seed = 42) + ggtb(
    
    sizeZoomin = 3             // <-- Point size can grow to 3x of the original size max.
)
Out[6]:
50 100 150 200 10 15 20 25 30 35 40 45 Efficiency vs Engine Horsepower miles per gallon engine horsepower origin of car US Europe Asia