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.3.tar.gz (382.7 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.3-py3-none-any.whl (382.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: mosaicmap-0.1.3.tar.gz
  • Upload date:
  • Size: 382.7 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.3.tar.gz
Algorithm Hash digest
SHA256 e444253dbc483df67676586585a60b67b71cf9206b33571eac89e8493b5d6bec
MD5 1566ae7518f081899f7af8f539253f66
BLAKE2b-256 bafe2a54431e80a50f7657fb9737055f3d590a54a26a69cf944299a2954cf25c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mosaicmap-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 382.8 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 b622db2e40f37f91ec2d8501644e25b8047d6f241126e0b93a585eadea50ea30
MD5 556223493dc8fbc01aebac2569fd6936
BLAKE2b-256 ceae3512c12b94e0951c2d80b065e0dc3d68f0587c0d88e013b33e0b2c03340b

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