Skip to main content

A lightweight Python library for easy data visualization with OOP principles

Project description

LightenPlot

Dramatically Simplify Data Visualization in Python

LightenPlot is a Python library that reduces complex visualization code into single-line commands, while maintaining the power and flexibility of matplotlib and seaborn.

Python Version License PyPI

Table of Contents

Features

  1. One-Line Plotting: Create beautiful visualizations with single commands
  2. Method Chaining: Fluent API for intuitive plot customization
  3. Built-in Themes: Multiple professional themes (default, dark, minimal, colorful)
  4. Comprehensive Plot Types: Scatter, line, bar, histogram, box, heatmap
  5. Smart Composition: Easily combine multiple plots
  6. Easy Export: Save in multiple formats (PNG, PDF, SVG)
  7. Full OOP Design: Encapsulation, inheritance, polymorphism

Installation

pip install LightenPlot

From Source

git clone https://github.com/khassndrajayme/LightenPlot.git
cd LightenPlot
pip install -r requirement.txt
pip install -e .

Quick Start

Traditional Way (10+ lines)

import matplotlib.pyplot as plt
import pandas as pd

data = pd.DataFrame({'x': [1, 2, 3, 4], 'y': [2, 4, 6, 8]})
fig, ax = plt.subplots(figsize=(10, 6))
ax.scatter(data['x'], data['y'], alpha=0.6)
ax.set_xlabel('X Values')
ax.set_ylabel('Y Values')
ax.set_title('My Scatter Plot')
ax.grid(True, alpha=0.3)
plt.tight_layout()
plt.show()

LightenPlot Way (1 line!)

import LightenPlot as lp
import pandas as pd

data = pd.DataFrame({'x': [1, 2, 3], 'y': [4, 5, 6]})
lp.scatter(data, x='x', y='y').set_title('My Scatter Plot').show()

PyPI Package:

https://pypi.org/project/LightenPlot/

lightenplot

Examples

Scatter Plot

import LightenPlot as lp
import pandas as pd

data = pd.DataFrame({
    'age': [25, 30, 35, 40, 45],
    'salary': [50000, 60000, 75000, 80000, 95000]
})

lp.scatter(data, x='age', y='salary', color='steelblue') \
  .set_title('Age vs Salary') \
  .set_labels('Age (years)', 'Salary ($)') \
  .apply_theme('minimal') \
  .save('plot.png') \
  .show()

Line Plot

lp.line(data, x='month', y='revenue', color='#FF6B6B', linewidth=2.5) \
  .set_title('Monthly Revenue') \
  .apply_theme('dark') \
  .show()

Bar Plot

lp.bar(data, x='category', y='value', color='#4ECDC4') \
  .set_title('Sales by Category') \
  .show()

Histogram

import numpy as np

ages = np.random.normal(35, 10, 1000)
lp.histogram(ages, bins=30, color='skyblue') \
  .set_title('Age Distribution') \
  .show()

Box Plot

lp.boxplot(data, columns=['Group_A', 'Group_B', 'Group_C']) \
  .set_title('Performance Comparison') \
  .show()

Heatmap

correlation_matrix = data.corr()
lp.heatmap(correlation_matrix, cmap='coolwarm', annot=True) \
  .set_title('Correlation Matrix') \
  .show()

Plot Composition

# Create individual plots
plot1 = lp.scatter(data, x='x', y='y')
plot2 = lp.line(data, x='date', y='value')
plot3 = lp.bar(data, x='cat', y='count')
plot4 = lp.histogram(values, bins=20)

# Compose into 2x2 grid
composer = lp.compose(rows=2, cols=2)
composer.add_plot(plot1).add_plot(plot2).add_plot(plot3).add_plot(plot4)
composer.show()

Themes

LightenPlot includes 4 built-in themes:

  • default: Clean, professional look
  • dark: Dark mode with high contrast
  • minimal: Minimalist design with no spines
  • colorful: Vibrant, eye-catching colors
# Apply theme
plot.apply_theme('dark')

# List available themes
print(lp.ThemeManager.list_themes())

Exporting Plots

# Single format
plot.save('output.png', dpi=300)

# Multiple formats
from LightenPlot import PlotExporter
exporter = PlotExporter(plot.figure)
exporter.save_multiple('output', formats=['png', 'pdf', 'svg'])

Architecture

LightenPlot is built with solid OOP principles:

Core Classes

  1. BasePlot: Abstract base class for all plots
  2. ScatterPlot, LinePlot, BarPlot, etc.: Specific plot implementations
  3. PlotComposer: Compose multiple plots (composition pattern)
  4. ThemeManager: Manage and apply themes (singleton pattern)
  5. PlotExporter: Handle plot exports

OOP Features Demonstrated

  1. Encapsulation: Private attributes (_data, _theme)
  2. Inheritance: All plots inherit from BasePlot
  3. Polymorphism: Theme classes with common interface
  4. Composition: PlotComposer contains BasePlot instances
  5. Dunder Methods: __repr__, __str__, __eq__, __lt__

API Reference

Quick Functions

Function Description
scatter() Create scatter plot
line() Create line plot
bar() Create bar plot
histogram() Create histogram
boxplot() Create box plot
heatmap() Create heatmap
compose() Create plot composer

Common Methods

Method Description
.set_title(title) Set plot title
.set_labels(x, y) Set axis labels
.apply_theme(name) Apply theme
.save(filename) Save plot
.show() Display plot

Testing

Run unit tests:

# Simple run
pytest tests/test_all.py

# Verbose (shows test names)
pytest tests/test_all.py -v

# Show print statements
pytest tests/test_all.py -v -s

# Stop on first failure
pytest tests/test_all.py -x

# Run specific test class
pytest tests/test_all.py::TestScatterPlot -v

# Run specific test method
pytest tests/test_all.py::TestScatterPlot::test_scatter_creation -v

# With coverage
pytest tests/test_all.py --cov=lightenplot --cov-report=term

# Run all tests in tests/ folder
pytest tests/

Or with unittest:

python -m unittest discover tests/

Contributing

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

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

RichieClan Team

  • Khassandra Louise C. Jayme - Lead Developer - GitHub
  • Sheena Angela T. Janog - Developer - GitHub
  • Xavier Neo Mahilum - Developer - GitHub
  • Allen Floro Ventura - Developer - GitHub
  • Genetyron Zamoranos - Developer - GitHub

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

  • Built on top of Matplotlib
  • Inspired by Seaborn
  • Thanks to our instructor for guidance and support
  • Inspired by matplotlib, seaborn, and ggplot2

Contact

For questions or feedback, please open an issue on GitHub or contact us at khassandrajayme@gmail.com


Made with Love by RichieClan

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

lightenplot-0.3.0.tar.gz (14.4 kB view details)

Uploaded Source

Built Distribution

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

lightenplot-0.3.0-py3-none-any.whl (14.1 kB view details)

Uploaded Python 3

File details

Details for the file lightenplot-0.3.0.tar.gz.

File metadata

  • Download URL: lightenplot-0.3.0.tar.gz
  • Upload date:
  • Size: 14.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.5

File hashes

Hashes for lightenplot-0.3.0.tar.gz
Algorithm Hash digest
SHA256 f9974333f782ab72ebe6d5adca98aa6fc54b86c704a72b037e95ba50815c8d94
MD5 d620f899d8078d28d3bf076d6e69151c
BLAKE2b-256 cbfae3c3fc4b240df94dca1af820cd8c8a6a756c3427879d5abd252cbcb1a8cb

See more details on using hashes here.

File details

Details for the file lightenplot-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: lightenplot-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 14.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.5

File hashes

Hashes for lightenplot-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 98462c4f202be71edc1e06c163470c825e26d4094f26bff03e4ac79857c9945b
MD5 8af8c66e208753fb288e0ee0b0005dca
BLAKE2b-256 86e351f72408250e7768891cf4e2eaf41830d0c5c5db0b9a1d49290347957b95

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