Skip to main content

A Python package for creating pyramid plots using Matplotlib.

Project description

Pyramid Plot

A Python package for creating pyramid plots using Matplotlib.

Installation

pip install pyramidplot

Usage

Using DataFrame

import pandas as pd
import matplotlib.pyplot as plt
from pyramidplot import pyramidplot

# Sample data
levels = ["Producers", "Primary Consumers", "Secondary Consumers", "Tertiary Consumers"]
values = [800, 400, 200, 150]

data = pd.DataFrame({
    "Level": levels,
    "Value": values
})

# Create plot
fig, ax = plt.subplots(figsize=(8, 6))
pyramidplot(
    data, 
    var_levels="Level", 
    var_values="Value", 
    ax=ax, 
    show_trend=True, 
    edgecolor='none',
    label_color='black',
    trend_color='gray'
)

plt.show()

Pyramid Plot Demo

Using Lists

import matplotlib.pyplot as plt
from pyramidplot import pyramidplot

levels = ["Producers", "Primary Consumers", "Secondary Consumers", "Tertiary Consumers"]
values = [800, 400, 200, 150]

fig, ax = plt.subplots(figsize=(8, 6))
pyramidplot(
    levels, 
    values, 
    ax=ax, 
    show_trend=True,
    edgecolor='none',
    label_color='black',
    trend_color='gray'
)
plt.show()

Features

  • Custom Levels and Values: Takes a DataFrame or two lists (levels, values).
  • Matplotlib Polygons: Uses Polygon patches to draw the pyramid levels (trapezoids).
  • Colormap Support: Allows specifying a colormap for level coloring.
  • Labels: Options to label levels and values.
  • Label Color: Option to specify label color or use the level color (default).
  • Trend Overlay: Option to show arrows and percentage change between levels (centered with labels, smaller size, padded).
  • Trend Color: Option to specify color for trend arrows and text (default 'gray').
  • Invert Trend: Use invert_trend=True (boolean) to invert trend arrows (downwards) and percentage sign (positive for loss).
  • Edge Customization: Option to customize or remove polygon edges using edgecolor.

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

pyramidplot-0.1.3.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyramidplot-0.1.3-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

Details for the file pyramidplot-0.1.3.tar.gz.

File metadata

  • Download URL: pyramidplot-0.1.3.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for pyramidplot-0.1.3.tar.gz
Algorithm Hash digest
SHA256 c079fd4237e585c2b5c8222c2e3a07337af1fddf517240f4f0d32b5287850f6a
MD5 f362fc9a849c7d9801c3bb2f71770c35
BLAKE2b-256 a17fb3fb1415da83fb30fcca48fecdf0ac6fa4734b39af591422326eb939de3a

See more details on using hashes here.

File details

Details for the file pyramidplot-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: pyramidplot-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 4.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for pyramidplot-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 02a13d84fcbee3acb9287bd2e0a9c2ba6981ed490c6ca43692cc2d123f9672e9
MD5 c16e5e5fb93dd5d27e4c54d39a0b0468
BLAKE2b-256 d7b667970365aa4fd828485438f6c1764f581fb232ae90890a23dac8326e6613

See more details on using hashes here.

Supported by

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