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:
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
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mosaicmap-0.1.4.tar.gz.
File metadata
- Download URL: mosaicmap-0.1.4.tar.gz
- Upload date:
- Size: 385.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ec1d14aabbd5bfec1388c3f9339a3baf8f0ba0103ac10505d809ebc202de346b
|
|
| MD5 |
2ee9d3bc35c4561ae5166e931915bf93
|
|
| BLAKE2b-256 |
6bc4adec4be7ff641edb86df9a555711c8cc8006004c20cafd97c22783dfbc73
|
File details
Details for the file mosaicmap-0.1.4-py3-none-any.whl.
File metadata
- Download URL: mosaicmap-0.1.4-py3-none-any.whl
- Upload date:
- Size: 385.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
55be7c5cc28cec869393e0bbdd0f00a2c309c2f04be99890533468a0f8e7416e
|
|
| MD5 |
c3904062560a0b62f980d39e98f275b7
|
|
| BLAKE2b-256 |
6144f3959381bf46a632151b1fd6112993f807ec709ca7f810adc563bba084a3
|