Notebook name: geom_point.ipynb
geom_point() draws markers on a scatter plot using different colors, shapes and sizes of markers.
[Optional Table of Contents]
import numpy as np
import pandas as pd
from lets_plot import *
from lets_plot.geo_data import *
from lets_plot.bistro import *
The geodata is provided by © OpenStreetMap contributors and is made available here under the Open Database License (ODbL).
LetsPlot.setup_html()
For demo, if possible, use standard data from lets-plot-docs repository.
For example:
df = pd.read_csv('https://raw.githubusercontent.com/JetBrains/lets-plot-docs/master/data/mpg.csv')
df.head(3)
Unnamed: 0 | manufacturer | model | displ | year | cyl | trans | drv | cty | hwy | fl | class | |
---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 1 | audi | a4 | 1.8 | 1999 | 4 | auto(l5) | f | 18 | 29 | p | compact |
1 | 2 | audi | a4 | 1.8 | 1999 | 4 | manual(m5) | f | 21 | 29 | p | compact |
2 | 3 | audi | a4 | 2.0 | 2008 | 4 | manual(m6) | f | 20 | 31 | p | compact |
The 1-st figure is usually built with a minimal set of required parameters.
In many cases chapter header is not necessary.
ggplot(df) + geom_point(aes(x="displ", y="hwy"))
color
and size
¶ggplot(df) + geom_point(aes(x="displ", y="hwy", color="drv", size="displ"))
shape
¶ggplot(df) + geom_point(aes(x="displ", y="hwy", shape="drv"), size=8)
ggplot(df) + geom_point(aes(x="displ", y="hwy", shape="drv"), size=8) + \
scale_shape(solid=False)
Can be used to draw markers using GeoDataFrame. Utilizes only POINT and MULTI_POINT, ignores other.