Skip to main content

A versatile Python toolkit for programmatically generating, manipulating, and assembling scalable vector graphics (SVG) images.

Project description

pyDreamplet

pyDreamplet is a low-level library for SVG image generation — perfect for creating beautiful data visualizations with Python. Its intuitive API lets you build complex, scalable SVG graphics effortlessly, making it an ideal choice for projects ranging from simple charts to intricate visualizations.

Features

  • Lightweight & Flexible: Generate SVG images with minimal overhead.
  • Easy Integration: Works seamlessly in Jupyter notebooks, scripts, or web applications.
  • Customizable: Set any attribute on your SVG elements using simple keyword arguments.
  • No Heavy Dependencies: Designed to work with just Python’s standard library (plus Pillow and IPython for additional features).

Installation

Install pyDreamplet using your preferred package manager:

With uv:

uv add pydreamplet

With pip:

pip install pydreamplet

Documentation

For complete documentation, tutorials, and API references, please visit pyDreampled documentation

Examples

Multidimensional Visualization of Supplier Quality Performance

This example showcases a sophisticated, multidimensional SVG visualization that displays supplier quality performance metrics. In this visualization, data dimensions such as defect occurrences, defect quantity, and spend are combined to provide an insightful overview of supplier performance. The visualization uses color, shape, and layout to encode multiple measures, allowing users to quickly identify strengths and weaknesses across suppliers.

supplier quality performance

Creative Coding

This example uses pyDreamplet to create an engaging animated visualization featuring a series of circles. The animation leverages dynamic properties like stroke color and radius, which are mapped using linear and color scales. Each circle’s position and size are animated over time, creating a pulsating, rotating effect that results in a visually striking pattern.

creative coding

Usage example

Here's a quick example of how to create a waffle chart using pyDreamplet:

import pydreamplet as dp
from pydreamplet.colors import random_color

data = [130, 65, 108]


def waffle_chart(data, side=300, rows=10, cols=10, gutter=5, colors=["blue"]):
    sorted_data = sorted(data, reverse=True)
    while len(colors) < len(sorted_data):
        colors.append(random_color())

    svg = dp.SVG(side, side)

    total_cells = rows * cols
    total = sum(data)
    proportions = [int(round(d / total * total_cells, 0)) for d in sorted_data]
    print("Proportions:", proportions)

    cell_side = (side - (cols + 1) * gutter) / cols

    cell_group_map = []
    for group_index, count in enumerate(proportions):
        cell_group_map.extend([group_index] * count)

    if len(cell_group_map) < total_cells:
        cell_group_map.extend([None] * (total_cells - len(cell_group_map)))

    paths = {i: "" for i in range(len(sorted_data))}

    for i in range(total_cells):
        col = i % cols
        row = i // cols

        x = gutter + col * (cell_side + gutter)
        y = gutter + row * (cell_side + gutter)

        group = cell_group_map[i]
        if group is not None:
            paths[group] += f"M {x} {y} h {cell_side} v {cell_side} h -{cell_side} Z "

    for group_index, d_str in paths.items():
        if d_str:
            path = dp.Path(d=d_str, fill=colors[group_index])
            svg.append(path)

    return svg


svg = waffle_chart(data)
svg.display()  # in jupyter notebook
svg.save("waffle_chart.svg")

waffle chart

Contributing

I welcome contributions from the community! Whether you have ideas for new features, bug fixes, or improvements to the documentation, your input is invaluable.

  • Open an Issue: Found a bug or have a suggestion? Open an issue on GitHub.
  • Submit a Pull Request: Improve the code or documentation? I’d love to review your PR.
  • Join the Discussion: Get involved in discussions and help shape the future of pyDreamplet.

License

This project is licensed under the MIT License.

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

pydreamplet-1.1.10.tar.gz (371.5 kB view details)

Uploaded Source

Built Distribution

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

pydreamplet-1.1.10-py3-none-any.whl (100.2 kB view details)

Uploaded Python 3

File details

Details for the file pydreamplet-1.1.10.tar.gz.

File metadata

  • Download URL: pydreamplet-1.1.10.tar.gz
  • Upload date:
  • Size: 371.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.13

File hashes

Hashes for pydreamplet-1.1.10.tar.gz
Algorithm Hash digest
SHA256 a83955a577dece1fdb7f61044e5625423591a8826e4c17c2dbe94a4bbca54c63
MD5 c7e6b14412d67c50366d0ed3bde44d99
BLAKE2b-256 920cfbb0b43ddde5fbe80417fd01e472ba8950b05b3c892730adba65cecb71be

See more details on using hashes here.

File details

Details for the file pydreamplet-1.1.10-py3-none-any.whl.

File metadata

File hashes

Hashes for pydreamplet-1.1.10-py3-none-any.whl
Algorithm Hash digest
SHA256 33eb261507c0c7595156e9ceac34077f1216f0ba611b5d14ceb1a89291300f86
MD5 43cf0003791e6afe7687b89c04df113f
BLAKE2b-256 f2e2c5d7fc0f0b338003210e3228699a6cad0a65100efbcb2a81efe77b999e64

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