Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pysal/legendgram
Legendgrams are distributional visualizations for map classification schemes
https://github.com/pysal/legendgram
Last synced: about 2 months ago
JSON representation
Legendgrams are distributional visualizations for map classification schemes
- Host: GitHub
- URL: https://github.com/pysal/legendgram
- Owner: pysal
- License: bsd-3-clause
- Created: 2017-11-09T15:42:45.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2024-05-16T14:13:02.000Z (4 months ago)
- Last Synced: 2024-07-21T18:59:30.631Z (2 months ago)
- Language: Python
- Size: 972 KB
- Stars: 49
- Watchers: 20
- Forks: 10
- Open Issues: 16
-
Metadata Files:
- Readme: README.rst
- License: LICENSE
Awesome Lists containing this project
README
Legendgrams
========================This is a small bit of unittested, reproducible code to provide legendgrams.
Legendgrams are map legends that visualize the distribution of observations by color in a given map:.. image:: https://raw.githubusercontent.com/pysal/legendgram/master/figs/brooklyn.png
:width: 40%
:height: 200px
:scale: 50%
:alt: Silhouettes in BrooklynLegendgrams are distributed by PySAL, an open source cross-platform library of spatial analysis functions
written in Python. It is intended to support the development of high level
applications for spatial analysis.To use legendgrams, simply install the package using pip:
.. code-block:: bash
$ pip install legendgram
Then, apply the function to the figure/axis you want to have a legendgram:
.. code-block:: python
>>> import pysal as ps, geopandas as gpd, matplotlib.pyplot as plt
>>> from legendgram import legendgram
>>> data = gpd.read_file(ps.examples.get_path('south.shp'))
>>> data.crs = {'init': 'epgs:4269'}
>>> data.to_crs(epsg=5070)
>>> f,ax = plt.subplots()
>>> data.plot('DV80', k=10, ax=ax, scheme='Quantiles')
>>> bins = ps.Quantiles(data['DV80'].values, k=10).bins
>>> from legendgram import legendgram
>>> import palettable.matplotlib as palmpl
>>> legendgram(f,ax,data['DV80'],bins,pal=palmpl.Viridis_10,
legend_size=(.5,.2), # legend size in fractions of the axis
loc = 'upper left' # matplotlib-style legend locations
clip = (2,10) # clip the displayed range of the histogram
).. image:: https://raw.githubusercontent.com/pysal/legendgram/master/figs/example.png
:width: 100%
:alt: Example legendgram map in the US southAn example notebook is provided_ as well.
.. _provided: https://github.com/pysal/legendgram/blob/master/examples/examples.ipynb
License
-------This is licensed under the 3-Clause BSD license.
Refer to the license file for more details.