Skip to main content

Quickly and easily draw basic Lexis diagrams

Project description

PyLexis

PyLexis is a tool to easily plot Lexis Diagrams within Python. It is based on matplotlib and inspirated in LexisPlotR.

What is a Lexis Diagram?

In demography a Lexis diagram (named after economist and social scientist Wilhelm Lexis) is a two dimensional diagram that is used to represent events (such as births or deaths) that occur to individuals belonging to different cohorts. Calendar time is usually represented on the horizontal axis, while age is represented on the vertical axis. (https://en.wikipedia.org/wiki/Lexis_diagram)

Installation

pip install pylexis

Using PyLexis

First import the package and create a Diagram object with the following arguments:

initial year, final_year, first_age, last_age

import pylexis
diagram = pylexis.Diagram(1910, 1920, 0, 10)

This returns a basic diagram:

Then you have a few methods to interact with the graph:

Diagram.titles(x_label, y_label, title)

Add title and axis labels.

Diagram.lexis_fill(target, value, color)

Highlight a certain age, year or cohort in the grid.

    Parameters
    ----------
    target: {'age', 'year' or 'cohort'}
    value: int with the value of the target selected.
    color: str with the colour to fill.

Diagram.add_births(year, value)

Draw number of births in a specific year.

Diagram.add_deaths(year, value)

Draw number of deaths in a specific year for a specific cohort.

    Parameters
    ----------
    cohort: Year of the cohort.
    year: Year of deaths.
    age: Age at the time of deaths. Deaths can be before or after birthdays.
    value: Deaths.

FAQ

Just ask me what you need!

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

pylexis-0.1.1.tar.gz (3.8 kB view details)

Uploaded Source

Built Distribution

pylexis-0.1.1-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

Details for the file pylexis-0.1.1.tar.gz.

File metadata

  • Download URL: pylexis-0.1.1.tar.gz
  • Upload date:
  • Size: 3.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.0.1 pkginfo/1.8.2 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

File hashes

Hashes for pylexis-0.1.1.tar.gz
Algorithm Hash digest
SHA256 0c713ffec755971be75fe177542d64b5d3a189639b5de6c5f6ed910418148cc0
MD5 aa3f6e47837923352a5eaa2ac9c4b79f
BLAKE2b-256 8ccef261163651b70f7f436688fd4a785bfdaba999f16a71e35de8fed3893aa0

See more details on using hashes here.

File details

Details for the file pylexis-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: pylexis-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 4.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.0.1 pkginfo/1.8.2 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

File hashes

Hashes for pylexis-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 464001707aa4494b8d70f1504b63e64ecf38d5961e278a4e98662f35c7c70e55
MD5 b8a0651764b9d7469253f28820827f71
BLAKE2b-256 4d036a91d68ba7de758c0b8f72b1bbb20817460ddb7b7e5a8005ea4bcdbbb5b0

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