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.2.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.2-py3-none-any.whl (382.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: mosaicmap-0.1.2.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.2.tar.gz
Algorithm Hash digest
SHA256 af94f90783255c4b1dad888dff56c90476831d9bb66001966755d5d90519293d
MD5 93d82516828e10147a7e7c59e336cb95
BLAKE2b-256 1e4791c7b0793dad05678e986f11122665630f9b6508283327e0320bbab2bfd0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mosaicmap-0.1.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 7813af5db5a20ef24ff0c2d855e99b3b03edb11e65379208572dcb7af1416f70
MD5 e9b22068b0d2a4251c5bb9f3b0db15fa
BLAKE2b-256 7c8dbd1cc6e161c07e59ee43c46c02187af34d2349f8aaa8d5338f0426c73b86

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