Mizani

0.14.4 · active · verified Thu Apr 09

Mizani is a Python library that provides a comprehensive set of 'scales' for graphics systems, mirroring the functionality of Hadley Wickham's popular R Scales package. It offers tools for data transformation, calculating aesthetically pleasing breaks for axes, and generating color palettes. The current version is 0.14.4, with releases occurring periodically, often in conjunction with Python version updates or fixes.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to use `mizani.breaks.breaks_log` to calculate visually appropriate logarithmic breaks for a given data range. This is a fundamental operation for creating readable plots with logarithmic scales.

import numpy as np
from mizani.breaks import breaks_log

# Define a range of data, e.g., from a logarithmic distribution
x = np.logspace(3, 6, 100) # 100 points from 10^3 to 10^6
limits = min(x), max(x)

# Calculate logarithmic breaks for the given limits
log_breaks = breaks_log()(limits)
print(f"Data limits: {limits}")
print(f"Calculated logarithmic breaks: {log_breaks}")

# You can also specify a base for the logarithm
log_breaks_base2 = breaks_log(base=2)(limits)
print(f"Calculated base-2 logarithmic breaks: {log_breaks_base2}")

view raw JSON →