Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
8 changes: 5 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
__pycache__/

build
jupyter_execute
source/generated
source/examples
source/gallery
source/gallery
source/gallery_py
source/pages/api
2 changes: 1 addition & 1 deletion docs/.buildinfo
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Sphinx build info version 1
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
config: 0adf304430f2fda758257fe547f78ce0
config: 4767841221894b33757b012ad1407921
tags: 645f666f9bcd5a90fca523b33c5a78b7
Binary file removed docs/.doctrees/_pages/installation.doctree
Binary file not shown.
Binary file removed docs/.doctrees/_pages/quickstart.doctree
Binary file not shown.
Binary file removed docs/.doctrees/api.doctree
Binary file not shown.
Binary file modified docs/.doctrees/environment.pickle
Binary file not shown.
Binary file modified docs/.doctrees/gallery/index.doctree
Binary file not shown.
Binary file modified docs/.doctrees/gallery/plot_geom_boxplot.doctree
Binary file not shown.
Binary file modified docs/.doctrees/gallery/plot_geom_histogram.doctree
Binary file not shown.
Binary file modified docs/.doctrees/gallery/plot_geom_path.doctree
Binary file not shown.
Binary file modified docs/.doctrees/gallery/plot_geom_point.doctree
Binary file not shown.
Binary file modified docs/.doctrees/gallery/plot_geopandas_kotlin_isl.doctree
Binary file not shown.
Binary file modified docs/.doctrees/gallery/sg_execution_times.doctree
Binary file not shown.
Binary file added docs/.doctrees/gallery_py/README.doctree
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed docs/.doctrees/generated/lets_plot.ggsave.doctree
Binary file not shown.
Binary file removed docs/.doctrees/generated/lets_plot.lims.doctree
Binary file not shown.
Binary file removed docs/.doctrees/generated/lets_plot.lon_lat.doctree
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed docs/.doctrees/generated/lets_plot.xlim.doctree
Binary file not shown.
Binary file removed docs/.doctrees/generated/lets_plot.ylim.doctree
Binary file not shown.
Binary file modified docs/.doctrees/index.doctree
Binary file not shown.
Binary file added docs/.doctrees/pages/api.doctree
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added docs/.doctrees/pages/api/lets_plot.ggsave.doctree
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added docs/.doctrees/pages/api/lets_plot.lims.doctree
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added docs/.doctrees/pages/api/lets_plot.xlim.doctree
Binary file not shown.
Binary file not shown.
Binary file added docs/.doctrees/pages/api/lets_plot.ylim.doctree
Binary file not shown.
Binary file added docs/.doctrees/pages/features.doctree
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added docs/.doctrees/pages/features/sampling.doctree
Binary file not shown.
Binary file modified docs/.doctrees/pages/installation.doctree
Binary file not shown.
Binary file added docs/.doctrees/pages/overview.doctree
Binary file not shown.
Binary file added docs/.doctrees/pages/overview/coordinates.doctree
Binary file not shown.
Binary file added docs/.doctrees/pages/overview/facets.doctree
Binary file not shown.
Binary file added docs/.doctrees/pages/overview/geoms.doctree
Binary file not shown.
Binary file added docs/.doctrees/pages/overview/ggbunch.doctree
Binary file not shown.
Binary file added docs/.doctrees/pages/overview/guide.doctree
Binary file not shown.
Binary file not shown.
Binary file added docs/.doctrees/pages/overview/positions.doctree
Binary file not shown.
Binary file added docs/.doctrees/pages/overview/scales.doctree
Binary file not shown.
Binary file modified docs/.doctrees/pages/quickstart.doctree
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
"""
Geom Boxplot
============

"""

import numpy as np

from lets_plot import *
LetsPlot.setup_html()

#%%

# sphinx_gallery_thumbnail_path = "/Users/vdovidaytis/Projects/lets-plot-docs/source/../examples/geom_boxplot.png"

np.random.seed(42)
n = 100
data = {'y': np.random.normal(size=n), \
'class': np.random.randint(5, size=n)}

# %%

ggplot(data, aes(x='class', y='y')) + \
geom_boxplot(aes(fill='class', color='class'), alpha=.5) + \
"""
Geom Boxplot
============
"""
import numpy as np
from lets_plot import *
LetsPlot.setup_html()
#%%
# sphinx_gallery_thumbnail_path = "E:\Projects\DataPad\Subprojects\LetsPlotDocs\MyFork\lets-plot-docs\source\gallery_py\geom_boxplot.png"
np.random.seed(42)
n = 100
data = {'y': np.random.normal(size=n), \
'class': np.random.randint(5, size=n)}
# %%
ggplot(data, aes(x='class', y='y')) + \
geom_boxplot(aes(fill='class', color='class'), alpha=.5) + \
scale_color_discrete() + scale_fill_discrete()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
"""
Geometry geom_point()
=====================

An example with the geom_point() geometry.

"""

import numpy as np

from lets_plot import *
LetsPlot.setup_html()

# %%

np.random.seed(42)
n = 100
x = np.random.uniform(-5, 5, size=n)
y = x ** 2 + np.random.normal(size=n)
data = {'x': x, 'y': y}

# %%

"""
Geometry geom_point()
=====================
An example with the geom_point() geometry.
"""
import numpy as np
from lets_plot import *
LetsPlot.setup_html()
# %%
np.random.seed(42)
n = 100
x = np.random.uniform(-5, 5, size=n)
y = x ** 2 + np.random.normal(size=n)
data = {'x': x, 'y': y}
# %%
ggplot(data, aes(x='x', y='y')) + geom_point()
Expand Down
Binary file modified docs/_downloads/46b4cb42d5bb56cc39e2b5b2b520b38d/gallery_python.zip
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,133 +1,135 @@
"""
Inset Map of Kotlin Island
==========================

Kotlin island is situated in the Gulf of Finland and is one of the
districts of the city of Saint Petersburg in Russia.

This example shows how *Lets-Plot* *GeoPandas* integration can help to
build an inset map of Kotlin island.

"""

# sphinx_gallery_thumbnail_path = "/Users/vdovidaytis/Projects/lets-plot-docs/source/../examples/geopandas_kotlin_isl.png"

# %% [markdown]
#
# `The geodata is provided by © OpenStreetMap contributors and is made
# available here under the Open Database License
# (ODbL) <https://www.openstreetmap.org/copyright>`__.

# %%

import requests
import pandas as pd
import geopandas as gpd
from shapely.geometry import Point, shape, box

from lets_plot import *
LetsPlot.setup_html()

# %%

def osm_boundaries(osm_id):
requests.get('http://polygons.openstreetmap.fr/?id={0}'.format(osm_id))
response = requests.get('http://polygons.openstreetmap.fr/get_geojson.py?id={0}&params=0'.format(osm_id))
return gpd.GeoDataFrame(geometry=[ shape(response.json()['geometries'][0]) ])

# %%

# %% [markdown]
#
# Load boundaries of St.-Petersburg districts from OSM to GeoPandas *GeoDataFrame*.
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

# %%

spb_districts_ids = [1115082, 1114193, 1114252, 1114354, 1114806, 1114809, 337424, 1114895, 363103, 1115366, 338636, 368287, 1114905, 367375, 1115367, 338635, 369514, 1114902]
spb_gdf = pd.concat([osm_boundaries(osm_id) for osm_id in spb_districts_ids])

# %%

# %% [markdown]
#
# Create a map showing all the districts of St.-Petersburg.
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# This map will become an **inset map**. The red rectangle indicates the
# bounds of the future **main map**.

# %%

kotlin_bbox = [29.63, 59.965, 29.815, 60.035]
kotlin_rect = dict(zip(['xmin', 'ymin', 'xmax', 'ymax'], kotlin_bbox))

# %%

spb_plot = ggplot() + \
geom_rect(map=gpd.GeoDataFrame(geometry=[box(*spb_gdf.geometry.total_bounds)]), color='black', fill='white') + \
geom_polygon(map=spb_gdf, color='#a1d99b', fill='#f7fcf5') + \
geom_rect(**kotlin_rect, color='red', alpha=0) + \
geom_text(label='Saint Petersburg', x=30.334445, y=59.934294, color='black', size=6) + \
theme(legend_position='none', axis_title='blank', axis_text='blank', axis_ticks='blank', axis_line='blank')
spb_plot

# %%

# %% [markdown]
#
# Create the main map with only Kotlin island on it.
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# We use ``xlim`` and ``ylim`` parameters of the coordinate system to crop
# the entire map containing all the districts of St.-Petersburg.

# %%

# GeoDataFrame containing names and coordinates of some tourist attractions to show on the main map.
places_gdf = gpd.GeoDataFrame({
'name' : [
'Kronstadt Naval Cathedral',
'Kronstadt History Museum',
'Kronstadt Naval Museum',
'City Russian Cemetery',
'Kronstadt Lutheran Cemetery',
'Vladimir Church',
],
'type' : ['church', 'museum', 'museum', 'cemetery', 'cemetery', 'church'],
'geometry' : [
Point(29.777455, 59.991744),
Point(29.791317, 59.986777),
Point(29.763422, 59.996108),
Point(29.706130, 60.019788),
Point(29.749861, 60.002212),
Point(29.766254, 59.998515),
],
})

# %%

# Cut-out the Kotlin area and add layes with text and points of interest.
kotlin_plot = ggplot() + \
geom_rect(**kotlin_rect, fill='#aadaff', alpha=0.2) + \
geom_polygon(map=spb_gdf, color='#31a354', fill='#e5f5e0') + \
geom_point(aes(color='type', shape='type'), data=places_gdf, size=5) + \
geom_text(aes(label='name'), data=places_gdf, hjust='right', position=position_nudge(x=-.002)) + \
geom_text(label='Kotlin Isl.', x=29.725, y=60.011, color='#31a354', size=13, fontface='italic') + \
geom_text(label='Gulf of Finland', x=29.665, y=60.002, color='#578bcc', size=11, fontface='italic') + \
coord_cartesian(xlim=kotlin_bbox[0::2], ylim=kotlin_bbox[1::2]) + \
ggtitle('Tourist attractions on Kotlin island') + \
theme(legend_position=(0.2, 0.2), axis_title='blank', axis_text='blank', axis_ticks='blank', axis_line='blank')
kotlin_plot

# %%

# %% [markdown]
#
# Finally, use *GGBunch* to show these two maps together.
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

# %%

bunch = GGBunch()
bunch.add_plot(kotlin_plot, 0, 0, 800, 600)
bunch.add_plot(spb_plot, 600, 25, 200, 150)
"""
Inset Map of Kotlin Island
==========================

Kotlin island is situated in the Gulf of Finland and is one of the
districts of the city of Saint Petersburg in Russia.

This example shows how *Lets-Plot* *GeoPandas* integration can help to
build an inset map of Kotlin island.

"""

# sphinx_gallery_thumbnail_path = "E:\Projects\DataPad\Subprojects\LetsPlotDocs\MyFork\lets-plot-docs\source\gallery_py\geopandas_kotlin_isl.png"

# %% [markdown]
#
# `The geodata is provided by © OpenStreetMap contributors and is made
# available here under the Open Database License
# (ODbL) <https://www.openstreetmap.org/copyright>`__.

# %%

import requests
import pandas as pd
import geopandas as gpd
from shapely.geometry import Point, shape, box

from lets_plot import *
LetsPlot.setup_html()

# %%

def osm_boundaries(osm_id):
requests.get('http://polygons.openstreetmap.fr/?id={0}'.format(osm_id))
response = requests.get('http://polygons.openstreetmap.fr/get_geojson.py?id={0}&params=0'.format(osm_id))
return gpd.GeoDataFrame(geometry=[ shape(response.json()['geometries'][0]) ])

# %%

# %% [markdown]
#
# Load boundaries of St.-Petersburg districts from OSM to GeoPandas *GeoDataFrame*.
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

# %%

spb_districts_ids = [1115082, 1114193, 1114252, 1114354, 1114806, 1114809, 337424, 1114895, 363103, 1115366, 338636, 368287, 1114905, 367375, 1115367, 338635, 369514, 1114902]
spb_gdf = pd.concat([osm_boundaries(osm_id) for osm_id in spb_districts_ids])

# %%

# %% [markdown]
#
# Create a map showing all the districts of St.-Petersburg.
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# This map will become an **inset map**. The red rectangle indicates the
# bounds of the future **main map**.

# %%

kotlin_bbox = [29.63, 59.965, 29.815, 60.035]
kotlin_rect = dict(zip(['xmin', 'ymin', 'xmax', 'ymax'], kotlin_bbox))

# %%

spb_plot = ggplot() + \
geom_rect(map=gpd.GeoDataFrame(geometry=[box(*spb_gdf.geometry.total_bounds)]), color='black', fill='white') + \
geom_polygon(map=spb_gdf, color='#a1d99b', fill='#f7fcf5') + \
geom_rect(**kotlin_rect, color='red', alpha=0) + \
geom_text(label='Saint Petersburg', x=30.334445, y=59.934294, color='black', size=6) + \
theme(legend_position='none', axis_title='blank', axis_text='blank', axis_ticks='blank', axis_line='blank')
spb_plot

# %%

# %% [markdown]
#
# Create the main map with only Kotlin island on it.
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# We use ``xlim`` and ``ylim`` parameters of the coordinate system to crop
# the entire map containing all the districts of St.-Petersburg.

# %%

# GeoDataFrame containing names and coordinates of some tourist attractions to show on the main map.
places_gdf = gpd.GeoDataFrame({
'name' : [
'Kronstadt Naval Cathedral',
'Kronstadt History Museum',
'Kronstadt Naval Museum',
'City Russian Cemetery',
'Kronstadt Lutheran Cemetery',
'Vladimir Church',
],
'type' : ['church', 'museum', 'museum', 'cemetery', 'cemetery', 'church'],
'geometry' : [
Point(29.777455, 59.991744),
Point(29.791317, 59.986777),
Point(29.763422, 59.996108),
Point(29.706130, 60.019788),
Point(29.749861, 60.002212),
Point(29.766254, 59.998515),
],
})

# %%

# Cut-out the Kotlin area and add layes with text and points of interest.
kotlin_plot = ggplot() + \
geom_rect(**kotlin_rect, fill='#aadaff', alpha=0.2) + \
geom_polygon(map=spb_gdf, color='#31a354', fill='#e5f5e0') + \
geom_point(aes(color='type', shape='type'), data=places_gdf, size=5) + \
geom_text(aes(label='name'), data=places_gdf, hjust='right', position=position_nudge(x=-.002)) + \
geom_text(label='Kotlin Isl.', x=29.725, y=60.011, color='#31a354', size=13, fontface='italic') + \
geom_text(label='Gulf of Finland', x=29.665, y=60.002, color='#578bcc', size=11, fontface='italic') + \
coord_cartesian(xlim=kotlin_bbox[0::2], ylim=kotlin_bbox[1::2]) + \
ggtitle('Tourist attractions on Kotlin island') + \
theme(legend_position=(0.2, 0.2), axis_title='blank', axis_text='blank', axis_ticks='blank', axis_line='blank')
kotlin_plot

# %%

# %% [markdown]
#
# Finally, use *GGBunch* to show these two maps together.
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

# %%

bunch = GGBunch()
bunch.add_plot(kotlin_plot, 0, 0, 800, 600)
bunch.add_plot(spb_plot, 600, 25, 200, 150)
bunch
Expand Down
Loading