size_unit='min' and size_unit='max'¶These options provide control over element sizing by automatically adapting to plot dimensions and aspect ratios.
The 'min' option is particularly useful for ensuring elements fit within plot boundaries regardless of the plot's size or form factor.
from lets_plot import *
LetsPlot.setup_html()
data = {'name': ['a', 'b', 'c', 'd', 'b'], 'value': [40, 90, 10, 50, 20]}
size_unit='min'¶pie_size_unit_min = (ggplot(data)
+ geom_pie(aes(fill='name', weight='value'),
size=.95, # <-- set size in relative units
size_unit='min') # <-- set the size unit to the smaller of the unit steps along the x and y axes
)
ggbunch([
pie_size_unit_min,
pie_size_unit_min,
pie_size_unit_min,
pie_size_unit_min,
],
regions=[
(0, 0, 0.6, 0.4),
(0.6, 0, 0.4, 0.7),
(0.1, 0.4, 0.3, 0.6),
(0.4, 0.7, 0.6, 0.3),
]
) + theme_bw() + ggsize(800, 600)
size_unit='max'¶pie_size_unit_max = (ggplot(data)
+ geom_pie(aes(fill='name', weight='value'),
size=.95, # <-- set size in relative units
size_unit='max') # <-- set the size unit to the larger of the unit steps along the x and y axes
)
ggbunch([
pie_size_unit_max,
pie_size_unit_max,
pie_size_unit_max,
pie_size_unit_max,
],
regions=[
(0, 0, 0.6, 0.4),
(0.6, 0, 0.4, 0.7),
(0.1, 0.4, 0.3, 0.6),
(0.4, 0.7, 0.6, 0.3),
]
) + theme_bw() + ggsize(800, 600)