Skip to main content

Mundane plotting done easy.

Project description

plotEZ

Mundane plotting made easy.

GitHub Release PyPI - Python Version GitHub-licence GiHub-CodeCoverage GitHub top language GitHub contributors Github Issues GitHub OPEN PRs GitHub CLOSED PRs

plotez is a Python library that simplifies common matplotlib plotting tasks with an intuitive API. Create complex plots with minimal boilerplate code.

Project Status

Item Status
Latest version v0.3.3
Python support 3.10 · 3.11 · 3.12
Test coverage 85%+
Type hints PEP 561 compliant (py.typed)
Documentation Read the Docs
Changelog CHANGELOG
License MIT

Features

  • Simple API: Create complex plots with just a few lines of code
  • Error Bar Plotting: Comprehensive error bar support with enhanced styling options
  • Error Band Plotting: Shaded error band support via plot_errorband, plot_errorband_relative, and ErrorBandConfig
  • Histogram & Density Plotting: plot_hist and plot_density with HistogramConfig / hgc
  • Dual-Axis Support: Easy creation of dual y-axis or dual x-axis plots
  • Multi-Panel Layouts: Flexible subplot arrangements with automatic labeling
  • File Integration: Direct plotting from CSV files
  • Extensive Customization: Full control over plot appearance via parameter classes
  • Custom Exceptions: Domain-specific exceptions for clear, catchable error handling
  • Early Input Validation: Clear ShapeError, DataLengthError, and EmptyDataError failures before matplotlib
  • Type Safety: Complete type hints for better IDE support and type checking (PEP 561 compliant)
  • Well Tested: Comprehensive test suite with 85%+ coverage

Installation

From PyPI

pip install plotez

From Source

git clone https://github.com/syedalimohsinbukhari/plotez.git
cd plotez
pip install -e .

Development Installation

pip install -e ".[dev]"

Quick Start

import numpy as np
from plotez import plot_xy

x = np.linspace(0, 10, 100)
y = np.sin(x)
plot_xy(x, y)

README_E1_simple

That's it. Three lines for a labeled plot.

Examples

Scientific Error Bars

import numpy as np
from plotez import plot_errorbar
from plotez.backend import ErrorPlotConfig

rng = np.random.default_rng(1234)

x = np.linspace(0, 10, 20)
y = np.sin(x)
y_err = 0.2 * rng.random(size=y.shape)

ep = ErrorPlotConfig(color="darkblue", marker="o", capsize=5, ecolor="red", markerfacecolor="lime")
plot_errorbar(x, y, y_err=y_err, errorbar_config=ep)

README_E2_scientific_errorbars

Professional error bars in a few lines of config. ecolor sets the error bar colour independently from the line colour.


Dual Y-Axis

import numpy as np
from plotez import plot_xyy

x = np.linspace(0, 10, 100)
y1 = np.sin(x)
y2 = np.exp(-x / 10)

plot_xyy(x, y1, y2, x_label="Time (s)", y1_label="Signal (V)", y2_label="Decay",
         data_labels=["Oscillation", "Envelope"])

README_E3_dual_y_axis

Dual axes done right. No ax.twinx() gymnastics.


Multi-Panel Grid

import numpy as np
from plotez import n_plotter

x_data = np.linspace(0, 10, 100)
y_data = [np.sin(x_data), np.cos(x_data),
          np.tan(x_data / 5), x_data ** 2 / 100]

n_plotter(x_data, y_data, n_rows=2, n_cols=2)

README_E4_multi_panel_grid

Four plots, one function call.


Error Bands

Use ErrorBandConfig and LinePlotConfig for explicit, IDE-friendly configuration:

import numpy as np
from plotez import plot_errorband
from plotez.backend import ErrorBandConfig, LinePlotConfig

x = np.linspace(0, 10, 50)
y = np.sin(x)
y_lower = y - 0.2
y_upper = y + 0.2

band_config = ErrorBandConfig(color="darkblue", alpha=0.25)
plot_config = LinePlotConfig(color="gold", linewidth=2, linestyle="--",
                             marker="o", markersize=5, markeredgecolor="k")

plot_errorband(x, y, y_lower, y_upper,
               data_label="Measurement", band_config=band_config, line_config=plot_config)

README_E5-1_error_band

The same result using the ebc / lpc shorthand aliases — familiar matplotlib parameter names, no class imports needed:

import numpy as np
from plotez import ebc, lpc, plot_errorband

x = np.linspace(0, 10, 50)
y = np.sin(x)
y_lower = y - 0.2
y_upper = y + 0.2

band_config = ebc(c="darkblue", alpha=0.25)
plot_config = lpc(c="gold", lw=2, ls="--", marker="o", ms=5, mec="k")

plot_errorband(x, y, y_lower, y_upper,
               data_label="Measurement", band_config=band_config, line_config=plot_config)

README_E5-2_error_band


Full Customization

import numpy as np
from plotez import plot_xyy
from plotez.backend import LinePlotConfig

x = np.linspace(0, 10, 50)
y1, y2 = np.sin(x), np.cos(x)

config = LinePlotConfig(
    linestyle=["--", "-."],
    color=["crimson", "gold"],
    marker=["o", "s"],
    markersize=[8, 8],
    markeredgecolor=["black", "black"],
    _extra={"markevery": [5, 5]},
)

plot_xyy(x, y1, y2, plot_config=config)

README_E6_full_customization

Config classes for when defaults aren't enough. Use _extra to pass any matplotlib parameter not covered by the dataclass fields.


Histogram / Density

Use plot_hist with the hgc shorthand to configure and plot a histogram in one go. Switch to plot_density to get normalised probability density instead of raw counts — everything else stays the same. Both functions accept one 1D dataset per call.

import numpy as np
from plotez import hgc, plot_hist

rng = np.random.default_rng(42)
data = rng.normal(loc=0, scale=1, size=5000)

h_cfg = hgc(bins=40, color="steelblue", ec="white", alpha=0.8)
plot_hist(data, x_label="Value", y_label="Counts",
          plot_title="Histogram of Normal Distribution",
          data_label="Normal", hist_config=h_cfg)

README_E7_histogram

Swap plot_hist for plot_density to get the probability density on the y-axis.

Development

Running Tests

pytest

With Coverage Report

pytest --cov=src/plotez --cov-report=html

Type Checking

mypy src/plotez

Building Documentation

cd docs
make html

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT License – see LICENSE file for details.

Authors

Links

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

plotez-0.3.3.tar.gz (35.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

plotez-0.3.3-py3-none-any.whl (22.4 kB view details)

Uploaded Python 3

File details

Details for the file plotez-0.3.3.tar.gz.

File metadata

  • Download URL: plotez-0.3.3.tar.gz
  • Upload date:
  • Size: 35.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for plotez-0.3.3.tar.gz
Algorithm Hash digest
SHA256 647b96329d234dfdbb8e94a6d27b0a66348fab954b8320894de43d3dcf9b0763
MD5 196258072c899e20b3e2770a704ddfd6
BLAKE2b-256 114178e7689645fb338d50f729f75b8664beec2275a4231b4f0beacec42bdcfc

See more details on using hashes here.

File details

Details for the file plotez-0.3.3-py3-none-any.whl.

File metadata

  • Download URL: plotez-0.3.3-py3-none-any.whl
  • Upload date:
  • Size: 22.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for plotez-0.3.3-py3-none-any.whl
Algorithm Hash digest
SHA256 4ba3937b4af7edbf3adf5f06dded686c75738f8b15a7a1767c67a79fa171bdc0
MD5 e8322ab14897573aee244adbb2a4c724
BLAKE2b-256 ef01b662f2d7d7d5b1367e1f74b9b534fc719b3ec0b5062c4eabcc77da906b31

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