Skip to main content

An advanced and flexible scientific plotting toolkit.

Project description

English | ไธญๆ–‡

PyPI version Documentation Status License: GPL v3

boviz

boviz is an advanced Python toolkit designed for generating publication-quality scientific figures with minimal code. Built on top of Matplotlib, it simplifies the creation of complex plots like multi-curve comparisons, dual-axis charts, heatmaps, and schematic diagrams, all while automatically applying academic styling conventions.


โœจ Key Features

  • Publication-Ready Aesthetics: Automatically applies academic font styles (e.g., Times New Roman) and optimizes tick marks, labels, and legends for high-resolution output.
  • Streamlined Workflow:
    • CSV to Plot: The boviz.curves module allows you to generate complex comparison plots directly from CSV files with a single function call.
    • NumPy Support: Easily plot data directly from NumPy arrays.
  • Advanced Plotting Capabilities:
    • Residual Analysis: Automatically calculate and visualize the difference between experimental and simulation data.
    • Dual Y-Axis: Effortlessly create plots with two different Y-axes.
    • Heatmaps & Fields: Visualize 2D fields (e.g., from finite element analysis) with boviz.heatmap.
    • Schematics: Generate academic-style schematic diagrams (e.g., particle distributions) with boviz.schematic.
  • Automated Versioning: Uses setuptools_scm for seamless version management based on Git tags.

๐Ÿ“ฆ Installation

pip install boviz

Or, to install the development or latest version from source:

# Clone the repository
git clone https://github.com/bo-qian/boviz.git
cd boviz

# (Optional) Create a virtual environment
python -m venv venv && source venv/bin/activate

# Install the package from source
pip install .

๐Ÿ“– Usage

For detailed API documentation, tutorials, and more examples, please visit the official documentation: ๐Ÿ‘‰ https://boviz.readthedocs.io/zh-cn/latest/

You can quickly scaffold a new boviz-based project using the built-in CLI:

boviz init my_project

This command creates a new directory my_project with a recommended structure, including example scripts and configuration files. It helps you get started with best practices for organizing your plotting workflow.

Generated structure:

my_project/
โ”œโ”€โ”€ data/
โ”‚   โ””โ”€โ”€ example.csv
โ””โ”€โ”€ plot.py

After initialization, you can immediately start adding your data and scripts, and use boviz's plotting functions as shown below.


๐Ÿš€ Quick Example

from boviz import *

# Plot initial particle distribution schematic
plot_initial_particle_schematic(
  coordinates=[[90, 90], [150, 90]],
  radii=[30, 30],
  domain=[240, 180],
  title="Initial Particle Distribution",
  show=True,
  save=True
)

# Multiple feature curve plotting
plot_curves_csv(
  path=["example/data/test_plotkit_multifeature_data.csv"] * 4,
  label=["Exp 800K", "Exp 900K", "Sim 800K", "Sim 900K"],
  x=[0, 0, 0, 0],
  y=[1, 2, 3, 4],
  xy_label=["Time (s)", "Shrinkage Ratio"],
  title_figure="Shrinkage Comparison at Two Temperatures",
  use_marker=[True, True, False, False],
  legend_ncol=2,
  save=True,
  show=False
)

# Single curve plotting: Plot a single simulation curve
x = np.linspace(0, 4*np.pi, 200)
y = np.sin(x)
plot_curves(
    data=[(x, y)],
    label=["$\sin(x)$"],
    xy_label=("$x$", "$\sin(x)$"),
    title_figure="Sine Wave Example",
    save=True,
    show=True
)

# Particle heatmap example
plot_heatmap_particle(
    particle_x_num=2,
    particle_y_num=1,
    particle_radius=30,
    border=1,
    cmap='coolwarm',
    title_figure="Particle Heatmap Example",
    save=True,
    show=False
)
ๅˆๅง‹็ฒ’ๅญๅˆ†ๅธƒ็คบๆ„ๅ›พ
Initial Particle Distribution
ไธๅŒๆธฉๅบฆไธ‹็š„ๆ”ถ็ผฉ็އๅฏนๆฏ”
Shrinkage Comparison
ๆญฃๅผฆๆณข็คบไพ‹
Sine Wave Example
็ฒ’ๅญ็ƒญๅ›พ็คบไพ‹
Particle Heatmap Example

๐Ÿงช Testing

To run all tests, use:

python -m pytest

Note: On Windows, if you installed boviz in a Conda environment, make sure to run this command from the Conda terminal (Anaconda Prompt or your activated Conda shell), not from the default system terminal.

All core plotting functions are covered by unit tests under the tests/ directory, including:

  • Curve plotting (single and multi-feature)
  • Schematic particle distribution
  • Residual comparison
  • Style and legend configurations

๐Ÿ“ Project Structure

boviz/
โ”œโ”€โ”€ src/
โ”‚   โ””โ”€โ”€ boviz/
โ”‚       โ”œโ”€โ”€ __init__.py
โ”‚       โ”œโ”€โ”€ __main__.py          # Main entry point for the package
โ”‚       โ”œโ”€โ”€ cli.py               # Command-line interface for plotting
โ”‚       โ”œโ”€โ”€ config.py            # Global parameters and color sets
โ”‚       โ”œโ”€โ”€ curves.py            # Core curve plotting functions
โ”‚       โ”œโ”€โ”€ schematic.py         # Particle schematic functions
โ”‚       โ”œโ”€โ”€ heatmap.py           # Particle heatmap plotting
โ”‚       โ”œโ”€โ”€ style.py             # Default plot styling
โ”‚       โ””โ”€โ”€ utils.py             # Filename generator and helpers
โ”œโ”€โ”€ tests/                       # Pytest-based test cases
โ”œโ”€โ”€ example/                     # Example scripts and CSV data
โ”‚   โ”œโ”€โ”€ data/
โ”‚   โ””โ”€โ”€ test_example_plot.py
โ”œโ”€โ”€ figures/                     # Output figures (auto-generated)
โ”‚   โ””โ”€โ”€ ShowExample/             # Example figures for documentation
โ”œโ”€โ”€ requirements.txt             # Required dependencies
โ”œโ”€โ”€ pyproject.toml               # Build configuration
โ”œโ”€โ”€ setup.py                     # Legacy install config
โ”œโ”€โ”€ LICENSE
โ”œโ”€โ”€ README.md
โ””โ”€โ”€ README_zh.md                 # Chinese version of the README

๐Ÿ“š Dependencies

matplotlib>=3.0
numpy>=1.18
pandas>=1.0
pytest>=6.0
pathlib>=1.0
argparse>=1.4.0
meshio>=4.0
netCDF4>=1.5

Install via:

pip install -r requirements.txt

๐Ÿ™Œ Contributing

Feel free to contribute by:

  • Reporting issues and bugs
  • Improving documentation and examples
  • Submitting pull requests with enhancements or new plotting modules

All contributions are welcome and appreciated.


๐Ÿ“œ License

GNU General Public License v3 (GPLv3) License ยฉ 2025 Bo Qian


For advanced examples and API documentation, please refer to the tests/ and example/ directories, or explore the docstrings inside the src/boviz/ module.

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

boviz-0.3.3.tar.gz (508.1 kB view details)

Uploaded Source

Built Distribution

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

boviz-0.3.3-py3-none-any.whl (64.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: boviz-0.3.3.tar.gz
  • Upload date:
  • Size: 508.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for boviz-0.3.3.tar.gz
Algorithm Hash digest
SHA256 2052c851f97fe3dac70bf625e7e8de05401b55d051eb848fb8c0c87c410da2f4
MD5 6febc0c42bac3f596ed7874836f3a6cc
BLAKE2b-256 fabe54ca6688230eac2d1b3578b7af1321fc97c01aee5749523f20fd34c0a5c8

See more details on using hashes here.

Provenance

The following attestation bundles were made for boviz-0.3.3.tar.gz:

Publisher: publish.yml on bo-qian/boviz

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

  • Download URL: boviz-0.3.3-py3-none-any.whl
  • Upload date:
  • Size: 64.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for boviz-0.3.3-py3-none-any.whl
Algorithm Hash digest
SHA256 9fc3f207655b108af51d0ead7821d9a3c3bf6e798b3fb9bc48b6061fd20a1d91
MD5 2d73c4a5b6868bb2645504d54d6903ad
BLAKE2b-256 a5c1cdc63cdb193d2c510fb07c6fd837d798256b3ec9c8628b1a20b72dd4a3b6

See more details on using hashes here.

Provenance

The following attestation bundles were made for boviz-0.3.3-py3-none-any.whl:

Publisher: publish.yml on bo-qian/boviz

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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