In [ ]:
from pandas import DataFrame
import numpy as np
from lets_plot import *

LetsPlot.setup_html()
In [ ]:
# Load MPG dataset
import pandas as pd

mpg = pd.read_csv ("https://raw.githubusercontent.com/JetBrains/lets-plot-docs/master/data/mpg.csv")
In [ ]:
ggplot(mpg, aes('displ', 'hwy', color='manufacturer')) \
+ geom_point(size=5, tooltips=layer_tooltips()
                          .anchor('top_right')
                          .min_width(180)  
                          .line('@manufacturer @model')
                          .line('cty/hwy|@cty/@hwy')
                          .line('@|@class')
                          .line('@|@year'))\
+ theme(legend_position='bottom') \
+ ggsize(500,400)
In [ ]:
# Load the iris dataset
iris_df = pd.read_csv('https://raw.githubusercontent.com/JetBrains/lets-plot-docs/master/data/iris.csv')
In [ ]:
(ggplot(iris_df) 
  + geom_area(aes(x='sepal_length', fill='species'), 
             stat='density',
             color='white',
             tooltips=layer_tooltips()
                .anchor('top_right')
                .line('^fill')
                .line('length|^x')
                .line('density|^y'))
 + ggsize(650, 300) 
)
In [ ]:
# Two layers with their own tooltip anchor settings
ggplot(iris_df) \
+ geom_line(aes(x='sepal_length', y='sepal_width'), colour='magenta',
            tooltips=layer_tooltips().line('width|^y').anchor('top_right')) \
+ geom_line(aes(x='petal_length', y='petal_width'), color='blue',
            tooltips=layer_tooltips().line('width|^y').anchor('top_left'))
In [ ]:
ggplot(iris_df) \
+ geom_line(aes(x='sepal_length', y='sepal_width'), colour='magenta',
            tooltips=layer_tooltips().line('sepal width|^y').anchor('top_right')) \
+ geom_line(aes(x='petal_length', y='petal_width'), color='blue',
            tooltips=layer_tooltips().line('petal width|^y').anchor('bottom_right'))
In [ ]:
ggplot(iris_df) \
+ geom_line(aes(x='sepal_length', y='sepal_width'), colour='magenta',
            tooltips=layer_tooltips().line('sepal width|^y').anchor('middle_left')) \
+ geom_line(aes(x='petal_length', y='petal_width'), color='blue',
            tooltips=layer_tooltips().line('petal width|^y').anchor('middle_left'))