from lets_plot import *
from lets_plot.bistro import *
import pandas as pd
LetsPlot.setup_html()
df = {
'x': [1],
'y': [1],
's': [1]
}
ggplot(df, aes('x','y')) + geom_point() + ggtb()
size_zoomin parameter¶The size_zoomin parameter accepts an integer value:
0 — zoom in disabled (default)-1 — unlimited zoom in2 means the geometry can be scaled up to 2×.size_zoomin=0 zoom in disabled¶ggplot(df, aes('x','y')) + geom_point() + ggtb(size_zoomin=0)
size_zoomin=-1 unlimited zoom in¶ggplot(df, aes('x','y')) + geom_point() + ggtb(size_zoomin=-1)
size_zoomin=3 zoom is capped at three times.¶ggplot(df, aes('x','y')) + geom_point() + ggtb(size_zoomin=3)
size_zoomin value¶ggplot(df, aes('x','y')) + geom_point() + ggtb(size_zoomin=-3)
size_basis parameter¶The size_basis 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.size_basis="x"¶Try using rubber-band zoom along the x axis only (and then along the y axis) to see the effect.
ggplot(df, aes('x','y')) + geom_point(size=10) + ggtb(size_basis="x", size_zoomin=-1)
size_basis="y"¶ggplot(df, aes('x','y')) + geom_point(size=10) + ggtb(size_basis="y", size_zoomin=-1)
size_basis="min"¶ggplot(df, aes('x','y')) + geom_point(size=10) + ggtb(size_basis="min", size_zoomin=-1)
size_basis="max" default¶ggplot(df, aes('x','y')) + geom_point(size=10) + ggtb(size_basis="max", size_zoomin=-1)
ggplot(df, aes('x','y')) + geom_point() + ggtb(size_zoomin=-1)
ggplot(df, aes('x','y')) + geom_point(size=80) + ggtb(size_zoomin=-1)
ggplot(df, aes('x','y')) + geom_point(aes(size='s')) + ggtb(size_zoomin=-1)
size_unit¶Scaling from ggtb() is not applied to layers that use size_unit. However, it is still applied to the other layers.
ggplot(df, aes('x','y')) + \
geom_point(size=0.1, size_unit = 'x') + \
geom_point(size=2, color='red') + \
ggtb(size_zoomin=-1)
gggrid()¶ggtb() can only be added to the root gggrid(). All plots inside will use the same scaling settings. Adding ggtb() to plots inside gggrid() is not allowed.
gggrid(
[
ggplot(df, aes('x','y')) + geom_point(size=10),
gggrid([
ggplot(df, aes('x','y')) + geom_point(size=10),
ggplot(df, aes('x','y')) + geom_point(size=20)
])
]
) + ggtb(size_zoomin=-1, size_basis="x")
facet_wrap()¶mpg = pd.read_csv('https://raw.githubusercontent.com/JetBrains/lets-plot-docs/master/data/mpg2.csv')
p = (
ggplot(mpg,
aes('engine horsepower', 'miles per gallon',
color=as_discrete('origin of car',order=-1)))
+ geom_point()
+ theme_grey() + ggtitle('Efficiency vs Engine Horsepower')
)
p
p + facet_wrap(['origin of car', 'number of cylinders'], order=[-1, 1], ncol=3) + ggtb(size_zoomin=3)