Skip to main content

A Python library for creating treemaps with images

Project description

MosaicMap

A Python library for creating treemaps where rectangles are replaced with images. Perfect for visualizing data with visual representations.

Installation

pip install mosaicmap

Features

  • Create treemaps using local images
  • Two image fitting modes: 'crop' and 'stretch'
  • Simple and intuitive API
  • Customizable output size, background color, and labels

Usage

from mosaicmap import MosaicMap

# Initialize mosaicmap creator
mosaicmap = MosaicMap()

# Prepare your data
data = {
    'labels': ['Product A', 'Product B', 'Product C'],
    'values': [500, 300, 200],  # Size values for each rectangle
    'image_paths': ['path/to/image1.jpg', 'path/to/image2.jpg', 'path/to/image3.jpg']
}

# Create the mosaicmap
mosaicmap.create(
    data=data,
    output_path='output_mosaicmap.png',
    image_mode='crop',  # or 'stretch'
    width=800,
    height=600,
    background_color=(255, 255, 255),  # white
    show_labels=True,  # Enable labels, False by default
    font_size=16  # Optionally adjust font size
)

Image Modes

  • crop: Maintains image aspect ratio by cropping excess portions
  • stretch: Stretches or compresses images to fit exactly in their allocated rectangles

Requirements

  • Python 3.7+
  • Pillow
  • numpy
  • squarify
  • pandas

Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for 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

mosaicmap-0.1.0.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

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

mosaicmap-0.1.0-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file mosaicmap-0.1.0.tar.gz.

File metadata

  • Download URL: mosaicmap-0.1.0.tar.gz
  • Upload date:
  • Size: 6.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.5

File hashes

Hashes for mosaicmap-0.1.0.tar.gz
Algorithm Hash digest
SHA256 5ce8097df64e81c67286ee771c84370b22ea321180349fb4ccba46aba3435699
MD5 3cfe45ea256380c42b1597a6b34b5e6d
BLAKE2b-256 541150cc0f5c77a30b8e0b85eab8a85cec1e4ca781af24b9e56341c9104f5109

See more details on using hashes here.

File details

Details for the file mosaicmap-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: mosaicmap-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.5

File hashes

Hashes for mosaicmap-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1df84eb7076546019009352b9f193eb7ebf92bbfcd6dfa97b15d8f7519f9bbd5
MD5 5811736c2412fecea020c1f81eed2f09
BLAKE2b-256 d2e2d63f773d6811d2d9639f16db9254319a10440a354dcdab725f564fec7d94

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