Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doc inset maps #190

Draft
wants to merge 4 commits into
base: dev
Choose a base branch
from
Draft
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added docs/_static/inset_maps/inset_maps_fig1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
127 changes: 71 additions & 56 deletions docs/api_inset_maps.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,22 @@ How to create inset maps

Inset maps are used to show zoomed-in regions of a map and can be created with :py:meth:`Maps.new_inset_map`.

.. code-block:: python
:name: test_inset_maps_01
.. table::
:widths: 60 40
:align: center

+-----------------------------------------------------+---------------------------------------------------+
| .. code-block:: python | .. image:: _static/inset_maps/inset_maps_fig1.png |
| :name: test_inset_maps_1 | :align: center |
| | |
| from eomaps import Maps | |img_minsize| |
| m = Maps() | |
| m.add_feature.preset.coastline() | |
| m_i = m.new_inset_map(xy=(125, 40), radius=10) | |
| m_i.add_feature.preset.ocean() | |
| m_i.add_indicator_line() | |
+-----------------------------------------------------+---------------------------------------------------+

from eomaps import Maps
m = Maps() # the "parent" Maps-object (e.g. the "big" map)
m.add_feature.preset.coastline()
m_i = m.new_inset_map(xy=(125, 40), radius=10) # a new Maps-object that represents the inset-map
m_i.add_feature.preset.ocean() # it can be used just like any other Maps-objects!
m_i.add_indicator_line()

- An inset-map is defined by it's center-position and a radius
- The used boundary-shape can be one of:
Expand Down Expand Up @@ -51,31 +58,31 @@ To quickly re-position (and re-size) inset-maps, have a look at the :ref:`layout
:widths: 60 40
:align: center

+-----------------------------------------------------------------+--------------------------------------------+
| .. code-block:: python | .. image:: _static/minigifs/inset_maps.png |
| :name: test_inset_maps_02 | :align: center |
| | |
| from eomaps import Maps | |img_minsize| |
| m = Maps(Maps.CRS.PlateCarree(central_longitude=-60)) | |
| m.add_feature.preset.ocean() | |
| | |
| m_i = m.new_inset_map(xy=(5, 45), radius=10, | |
| plot_position=(.3, .5), plot_size=.7, | |
| boundary=dict(ec="r", lw=4), | |
| indicate_extent=dict(fc=(1,0,0,.5), | |
| ec="r", lw=1) | |
| ) | |
| m_i.add_indicator_line(m, c="r") | |
| | |
| m_i.add_feature.preset.coastline() | |
| m_i.add_feature.preset.countries() | |
| m_i.add_feature.preset.ocean() | |
| m_i.add_feature.cultural.urban_areas(fc="r", scale=10) | |
| m_i.add_feature.physical.rivers_europe(ec="b", lw=0.25, | |
| fc="none", scale=10) | |
| m_i.add_feature.physical.lakes_europe(fc="b", scale=10) | |
| | |
+-----------------------------------------------------------------+--------------------------------------------+
+-----------------------------------------------------------------+---------------------------------------------------+
| .. code-block:: python | .. image:: _static/inset_maps/inset_maps_fig2.png |
| :name: test_inset_maps_2 | :align: center |
| | |
| from eomaps import Maps | |img_minsize| |
| m = Maps(Maps.CRS.PlateCarree(central_longitude=-60)) | |
| m.add_feature.preset.ocean() | |
| | |
| m_i = m.new_inset_map(xy=(5, 45), radius=10, | |
| plot_position=(.3, .5), plot_size=.7, | |
| boundary=dict(ec="r", lw=4), | |
| indicate_extent=dict(fc=(1,0,0,.5), | |
| ec="r", lw=1) | |
| ) | |
| m_i.add_indicator_line(m, c="r") | |
| | |
| m_i.add_feature.preset.coastline() | |
| m_i.add_feature.preset.countries() | |
| m_i.add_feature.preset.ocean() | |
| m_i.add_feature.cultural.urban_areas(fc="r", scale=10) | |
| m_i.add_feature.physical.rivers_europe(ec="b", lw=0.25, | |
| fc="none", scale=10) | |
| m_i.add_feature.physical.lakes_europe(fc="b", scale=10) | |
| | |
+-----------------------------------------------------------------+---------------------------------------------------+

.. currentmodule:: eomaps.eomaps.Maps

Expand Down Expand Up @@ -103,27 +110,35 @@ For this purpose, EOmaps provides 2 convenience-functions:
- Note that this means that the classification specs as well as ``vmin``, ``vmax`` and the used ``colormap`` will be the same!


.. code-block:: python
:name: test_zoomed_in_data_maps

from eomaps import Maps
import numpy as np

x, y = np.meshgrid(np.linspace(-20, 20, 50), np.linspace(-50, 60, 100))
data = x + y

m = Maps(ax=131)
m.set_data(data, x, y)
m.set_shape.raster()
m.set_classify.Quantiles(k=10)
m.plot_map(cmap="tab10", vmin=-10, vmax=40)

# Create a new inset-map that shows a zoomed-in view on a given dataset
m_inset = m.new_inset_map(xy=(5, 20), radius=8, plot_position=(0.75, .5))

# inherit both the data and the classification specs from "m"
m_inset.inherit_data(m)
m_inset.inherit_classification(m)
.. table::
:widths: 60 40
:align: center

m_inset.set_shape.rectangles()
m_inset.plot_map(ec="k", lw=0.25)
+-------------------------------------------------------------------------------+--+
| .. code-block:: python | |
| :name: test_inset_maps_3 | |
| | |
| from eomaps import Maps | |
| import numpy as np | |
| | |
| x, y = np.meshgrid(np.linspace(-20, 20, 50), np.linspace(-50, 60, 100)) | |
| data = x + y | |
| | |
| m = Maps(ax=131) | |
| m.set_data(data, x, y) | |
| m.set_shape.raster() | |
| m.set_classify.Quantiles(k=10) | |
| m.plot_map(cmap="tab10", vmin=-10, vmax=40) | |
| | |
| # Create a new inset-map that shows a zoomed-in view on a given dataset | |
| m_inset = m.new_inset_map(xy=(5, 20), radius=8, plot_position=(0.75, .5)) | |
| | |
| # inherit both the data and the classification specs from "m" | |
| m_inset.inherit_data(m) | |
| m_inset.inherit_classification(m) | |
| | |
| m_inset.set_shape.rectangles() | |
| m_inset.plot_map(ec="k", lw=0.25) | |
| | |
| | |
+-------------------------------------------------------------------------------+--+
Loading