import math
import random
import numpy as np
from lets_plot import *
import pandas as pd
LetsPlot.setup_html()
mpg_df = pd.read_csv('https://raw.githubusercontent.com/JetBrains/lets-plot-docs/master/data/mpg.csv')
ggplot(mpg_df, aes(x='displ', y='hwy')) + geom_point() + geom_smooth( deg = 2)
random.seed(42)
n = 500
x_range = np.arange(-2 * math.pi, 2 * math.pi, 4 * math.pi / n)
y_range = x_range + np.sin(x_range) + np.array([random.gauss(0.0, 1.0) for i in range(n)])
df = pd.DataFrame({ 'x' : x_range, 'y' : y_range })
p = ggplot(df, aes(x='x', y='y')) + geom_point(shape=21, fill='yellow', color='#8c564b')
p + geom_smooth(method='lm', deg = 5, size=1.5, color='#d62728')