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 comparisons and part-to-whole relationships with striking visuals.

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

Example Ouptut

This example shows cities sized by time spent:

Example Output

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.1.tar.gz (619.2 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.1-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: mosaicmap-0.1.1.tar.gz
  • Upload date:
  • Size: 619.2 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.1.tar.gz
Algorithm Hash digest
SHA256 3923c440aa38cf0c672d089c48aaa20fd0e7626cd96b0a8b96f3b7782f38840d
MD5 aebc80de81fd8d5d9211956bdb0c0810
BLAKE2b-256 900f442c164f1faeac93621c8e1293463fc7cdc59eff0f6c9738f12d0971aecc

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mosaicmap-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 5.4 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7f7f3753360c8fb0be320c0e50a2e879e3313766a3016306b76fb63ffb96a4c7
MD5 b4638de030b2d55b5febb93f818bdad7
BLAKE2b-256 21810b1012d952a56951802c497d17ead92a429d96b5b159cd0d4c02c1441949

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