Skip to main content

Legendgrams are map legends that visualize the distribution of observations by color in a given map

Project description

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:

Silhouettes in Brooklyn

Legendgrams 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:

$ pip install legendgram

Then, apply the function to the figure/axis you want to have a legendgram:

>>> 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
               )
Example legendgram map in the US south

An example notebook is provided as well.

License

This is licensed under the 3-Clause BSD license. Refer to the license file for more details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

legendgram-0.0.3.tar.gz (683.8 kB view details)

Uploaded Source

Built Distribution

legendgram-0.0.3-py2.py3-none-any.whl (7.7 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file legendgram-0.0.3.tar.gz.

File metadata

  • Download URL: legendgram-0.0.3.tar.gz
  • Upload date:
  • Size: 683.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for legendgram-0.0.3.tar.gz
Algorithm Hash digest
SHA256 1345a2191323d38b210470177435c9292a21e5dd2449f327179e29413772a9fa
MD5 8cf2d1b71a31d7d20f54ac987ad1589c
BLAKE2b-256 561e28596cbe4bb73727ba59d1cf63f2ad69799a308840c6a3fd4d214111e26c

See more details on using hashes here.

File details

Details for the file legendgram-0.0.3-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for legendgram-0.0.3-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 71932cabca43434c3667e4f0c66dcde139ae5dfcdff3863845980b6f1278b711
MD5 4160ba6ddbf0de0777e899cf4a66415e
BLAKE2b-256 90298a03d693d26f6fc4476953c7a639f978836b47b49635447b80201b522c58

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page