import numpy as np
from lets_plot import *
LetsPlot.setup_html()
data = {'x':[1,3,5], 'y':[0,0,0], 'z': [1,2,3]}
# size_unit forces visible size of point with Aes.size == 1 to be equal to the unit of given scale.
ggplot(data) + geom_point(aes(x='x', y='y'), size = 1, size_unit='x')
# as previous, but with size = 2
ggplot(data) + geom_point(aes(x='x', y='y'), size = 2, size_unit='x')
# size = 0.4 , size_unit = 'y'
ggplot(data) + geom_point(aes(x='x', y='y'), size = 0.4, size_unit='y')
#with size and color mapped to z and scale_size_identity
ggplot(data) + geom_point(aes(x='x', y='y', size='z', color = 'z'), size_unit='x') + scale_size_identity()
#as previous example, but without scale_size_identity
ggplot(data) + geom_point(aes(x='x', y='y', size='z', color='z'), size_unit='x')
# size_unit for text fits 5 symbol string to given axis unit
ggplot(data) + geom_text(aes(x='x', y='y', label='x'), size = 1, size_unit='x', label_format='.2f')
# as previous, but size_unit = 'y' + angle = 90
ggplot(data) + geom_text(aes(x='x', y='y', label='x'), size = 1, size_unit='y', label_format='.2f', angle=90)
size_unit='max' and Rubber Band Zoom in ggtb()
ggplot(data) + geom_point(aes(x='x', y='y'), size=.1, size_unit='max') + ggtb()
size_unit='x' vs size_unit='max' when changing the aspect ratio of the plot in ggbunch()
data2 = {'name': ['a', 'b', 'c', 'd', 'b'], 'value': [40, 90, 10, 50, 20]}
ggbunch([
ggplot(data2) + geom_pie(aes(fill='name', weight='value'), size=.5, size_unit='x'),
ggplot(data2) + geom_pie(aes(fill='name', weight='value'), size=.5, size_unit='x')
], [
(0,0.4,0.8,0.2),
(0.8,0,0.2,1)
]) + ggsize(1000, 600)
ggbunch([
ggplot(data2) + geom_pie(aes(fill='name', weight='value'), size=.5, size_unit='max'),
ggplot(data2) + geom_pie(aes(fill='name', weight='value'), size=.5, size_unit='max')
], [
(0,0.4,0.8,0.2),
(0.8,0,0.2,1)
]) + ggsize(1000, 600)