import numpy as np
from lets_plot import *
LetsPlot.setup_html()
np.random.seed(42)
x_a = np.random.normal(-0.5, 1, 100)
y_a = np.random.normal(0, 1, 100)
cat_a = ['A' for x in range(100)]
x_b = np.random.normal(0.5, 1, 100)
y_b = np.random.normal(0, 1, 100)
cat_b = ['B' for x in range(100)]
data = {}
data['x'] = np.concatenate((x_a, x_b))
data['y'] = np.concatenate((y_a, y_b))
data['cat'] = np.concatenate((cat_a, cat_b))
p = ggplot(data, aes('x', fill='cat'))
p + geom_point(aes(y='y', color='cat'), size=3, alpha=0.8) + \
ggtitle('Scatter plot')
p + geom_histogram() + \
ggtitle('Default histogram')
p + geom_histogram(position='dodge') + \
ggtitle('Interleaved histogram')
p + geom_histogram(alpha=0.5, position='identity') + \
ggtitle('Overlaid semi transparent histogram')
p + geom_histogram(bins=10, color='white', size=0.5) + \
ggtitle('Histogram with bins=10')