-
Notifications
You must be signed in to change notification settings - Fork 0
docs: add basemap documentation and update index #48
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| Basemap Plot with Chartly | ||
| ========================= | ||
|
|
||
| Chartly supports geographic visualisation through basemap plotting | ||
| using the ``add_basemap(...)`` method. Users can display projected | ||
| contour data on a world map while keeping the plotting interface | ||
| simple and consistent with the rest of the package. | ||
|
|
||
| Example | ||
| ------- | ||
|
|
||
| The example below generates contour data, projects it onto a basemap, | ||
| and visualises the result using Chartly's high-level interface. | ||
|
|
||
| The following customization options can be passed through the ``customs`` | ||
| dictionary when creating a basemap plot: | ||
|
|
||
| - ``proj`` (str): Map projection type (e.g., "eck4") | ||
| - ``lon_0`` (int): Central longitude used during the basemap projection step | ||
| - ``draw_countries`` (bool): Draw country borders | ||
| - ``draw_parallels`` (bool): Draw latitude lines | ||
| - ``draw_meridians`` (bool): Draw longitude lines | ||
| - ``mask`` (array-like of bool): Boolean mask used to control hatched regions; required when ``hatch`` is enabled and ``hatch_customs.get("type") == "mask"``. | ||
| - ``contour`` (bool): Enable contour plotting | ||
| - ``hatch`` (bool): Enable hatching; when ``hatch_customs["type"] == "mask"``, hatched regions are determined by ``mask``. | ||
| - ``hatch_customs`` (dict): Customization options for hatching (for example, ``{"type": "mask"}``). | ||
|
|
||
| .. code-block:: python | ||
|
|
||
| import chartly | ||
| import numpy as np | ||
|
|
||
| super_axes_labels = { | ||
| "super_title": "Simple Usage Of Basemap Example", | ||
| "share_axes": False, | ||
| } | ||
|
|
||
| plot = chartly.Chart(super_axes_labels) | ||
|
|
||
| # Define grid size (latitude x longitude) | ||
| nlats, nlons = 73, 145 | ||
|
|
||
| # Create latitude and longitude grids | ||
| delta = 2.0 * np.pi / (nlons - 1) | ||
| lats = 0.5 * np.pi - delta * np.indices((nlats, nlons))[0, :, :] | ||
| lons = delta * np.indices((nlats, nlons))[1, :, :] | ||
|
|
||
| # Generate sample data over the grid | ||
| wave = 0.75 * (np.sin(2.0 * lats) ** 8 * np.cos(4.0 * lons)) | ||
| mean = 0.5 * np.cos(2.0 * lats) * ((np.sin(2.0 * lats)) ** 2 + 2.0) | ||
|
|
||
| # Combine into final dataset for plotting | ||
| z = wave + mean | ||
|
|
||
| plot.add_basemap( | ||
| lon=lons * 180.0 / np.pi, | ||
| lat=lats * 180.0 / np.pi, | ||
| values=z, | ||
| customs={ | ||
| "proj": "eck4", | ||
| "lon_0": 0, | ||
| "draw_countries": True, | ||
| "draw_parallels": True, | ||
| "draw_meridians": True, | ||
| "mask": z < 0, | ||
| "contour": True, | ||
| "hatch": True, | ||
| "hatch_customs": {"type": "mask"}, | ||
| }, | ||
| ) | ||
|
|
||
| plot.render() | ||
|
|
||
| This example uses the Eckert IV projection and overlays contour data | ||
| onto a global map. Masking and hatching are applied to highlight | ||
| specific regions of the dataset, improving the visual distinction of | ||
| key areas. | ||
|
|
||
| .. image:: _static/basemap_plot_example.png | ||
| :alt: Basemap Plot Example | ||
| :align: center | ||
| :height: 500px | ||
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.