Rekha: Semantic Plotting for Python

Rekha is a modern plotting library that combines an intuitive API with publication-quality output. Create beautiful, customizable visualizations with minimal code.

PyPI Version License Python Version

The Problem

Matplotlib is powerful but requires reinventing the wheel for every plot—no semantic interface.

Plotly Express has great semantics but limited customization and poor aesthetics for publications.

Seaborn has good defaults but restrictive API and complicated to use.

The Solution

Rekha delivers Plotly Express simplicity with matplotlib’s publication-quality output and unlimited customization, plus modern features like unit humanization and grayscale optimization.

From 15 lines to 1 line:

# Before: Typical matplotlib plotting
import matplotlib.pyplot as plt
fig, ax = plt.subplots(figsize=(10, 6))
for category in df['category'].unique():
    data = df[df['category'] == category]
    ax.scatter(data['x'], data['y'], label=category, s=50, alpha=0.7)
ax.set_xlabel('X Values')
ax.set_ylabel('Y Values')
ax.set_title('Scatter Plot by Category')
ax.legend()
ax.grid(True, alpha=0.3)
plt.tight_layout()
plt.show()

# After: Rekha plotting
import rekha as rk
fig = rk.scatter(df, x='x', y='y', color='category', title='Scatter Plot by Category')
fig.show()
Beautiful Scatter Plot Beautiful Scatter Plot

Key Features

🎨 Beautiful Defaults

Pre-configured themes optimized for both light and dark modes

📊 Unified Interface

Consistent API across all plot types with uniform styling options

🖨️ Print-Ready

Built-in support for grayscale printing with patterns and enhanced contrast

Performance

Optimized for both interactive exploration and production use

🔧 Customizable

Full access to matplotlib’s powerful customization while maintaining simplicity

Quick Start

Installation

pip install rekha

Basic Usage

import rekha as rk
import pandas as pd

# Your data (CSV, database, anywhere)
df = pd.read_csv('your_data.csv')

# One line = beautiful plot
fig = rk.scatter(df, x='column1', y='column2', color='category')
fig.show()

Save and Export

# Optimized formats for different use cases
fig.save('plot.svg', format='web')      # Web-ready SVG
fig.save('plot.pdf', format='paper')    # Publication PDF
fig.save('plot.png', format='social')   # High-res PNG

Plot Types

Rekha supports all major statistical visualizations with a unified interface:

📈 Line Plots

Time series, trends

Line Plot Line Plot

rk.line(df, x='date', y='price')

🔵 Scatter Plots

Relationships, correlations

Scatter Plot Scatter Plot

rk.scatter(df, x='x', y='y', color='group')

📊 Bar Charts

Categorical comparisons

Bar Chart Bar Chart

rk.bar(df, x='category', y='sales')

📊 Histograms

Data distributions

Histogram Histogram

rk.histogram(df, x='value', color='type')

📦 Box Plots

Statistical summaries

Box Plot Box Plot

rk.box(df, x='group', y='value')

🔥 Heatmaps

2D data, correlations

Heatmap Heatmap

rk.heatmap(correlation_matrix)

📈 CDFs

Cumulative distributions

CDF Plot CDF Plot

rk.cdf(df, x='response_time')

Every plot type. Same simple API. Beautiful results.

See the Plot Types for detailed guides and examples.

Documentation

Development

Indices and tables