Skip to main content

Modular matplotlib plotting helpers

Project description

Matplot Flex

CI

モジュール化されたサブプロット構成、テキストのフィット、基本レンダラーをまとめた Matplotlib 補助ライブラリです。

インストール(PyPI)

pip install matplot-flex

未公開の場合は GitHub から直接インストールできます。

pip install "matplot-flex @ git+https://github.com/obitsu-jo/matplot-flex.git"

対応環境

  • Python 3.10 以上

クイックスタート

import numpy as np
from matplot_flex import (
    AxisConfig, LegendConfig, SeriesSpec,
    plot_template, divide_fig_ratio, draw_graph_module, plot_on_module,
    render_line, render_multi,
)

fig, figs = plot_template("My Plot")
left_fig, right_fig = divide_fig_ratio(figs[1], "horizontal", ratios=[1, 1])

x = np.linspace(0, 10, 100)
y1 = np.sin(x)
y2 = np.cos(x)
series = [
    SeriesSpec(x=x, y=y1, renderer=render_line, label="sin"),
    SeriesSpec(x=x, y=y2, renderer=render_line, label="cos", linestyle="--"),
]

plot_on_module(
    draw_graph_module(left_fig),
    x,
    y1,
    "Sine & Cosine",
    renderer=lambda ax, xx, yy: render_multi(ax, series, legend=LegendConfig()),
    x_axis=AxisConfig(label="x"),
    y_axis=AxisConfig(label="value"),
    series_specs=series,  # ensures axes cover all series
)

fig.savefig("example.png", dpi=220)

構成

  • matplot_flex/config.py: 軸/凡例/グリッド設定。
  • matplot_flex/text_utils.py: テキストフィット、パラメータ整形、角丸フレーム、日付/指数フォーマッタ。
  • matplot_flex/renderers.py: 折れ線/散布/棒グラフ、複数系列補助、SeriesSpec
  • matplot_flex/layout.py: Figure/SubFigure 生成と plot_on_module の司令塔。
  • main.py: modular_subplot_example.png を生成するサンプル。
  • smoke_test.py: 生成確認の簡易テスト。

公開APIは matplot_flex/__init__.py から再エクスポートしています。
詳細なAPIノートは matplot_flex/README.md を参照してください。

サンプルの実行

python main.py

リポジトリ直下に modular_subplot_example.png を出力します。

CI

GitHub Actions で python smoke_test.py を実行します。

テスト

python smoke_test.py

PNG を再生成して、生成できたことを確認します。

python -m pytest -q

代表的な利用パターンの描画が通ることを確認します。

依存関係の方針

ライブラリ利用向けの範囲指定は pyproject.toml で管理し、開発・CI の再現性は requirements.txt の固定版で担保します。

開発環境の導入:

python -m venv .venv
. .venv/bin/activate
pip install -r requirements.txt
pip install -e .

バージョニング方針

SemVer(MAJOR.MINOR.PATCH)に従います。変更履歴は CHANGELOG.md を参照してください。

  • MAJOR: 互換性のない変更
  • MINOR: 後方互換のある機能追加
  • PATCH: 後方互換のあるバグ修正

ローカルパッケージとして導入(再利用向け)

pip install -e .

以降は同一環境の別ディレクトリから import matplot_flex できます。

PyPI 公開手順

  1. PyPI のアカウント作成と 2FA 設定
  2. pyproject.tomlversion を更新
  3. 配布物を作成
python -m build
  1. PyPI にアップロード
python -m twine upload dist/*

ライセンス

MIT License(LICENSE を参照)

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

matplot_flex-0.1.1.tar.gz (13.3 kB view details)

Uploaded Source

Built Distribution

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

matplot_flex-0.1.1-py3-none-any.whl (12.5 kB view details)

Uploaded Python 3

File details

Details for the file matplot_flex-0.1.1.tar.gz.

File metadata

  • Download URL: matplot_flex-0.1.1.tar.gz
  • Upload date:
  • Size: 13.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for matplot_flex-0.1.1.tar.gz
Algorithm Hash digest
SHA256 9287b5fb738204a3e3ffa5d32abd0cd351062feb35558c6d9d32ad240e94bf30
MD5 20bb038f7cd9905dbf22ebaa046513a3
BLAKE2b-256 7a124be8f1858c7d14e149c45f8e24561ed94010d1ceff0a38a7b4700f5994e6

See more details on using hashes here.

File details

Details for the file matplot_flex-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: matplot_flex-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 12.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for matplot_flex-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f0811e3b7f219fca356e746ff33feb55a0369423bf710d678e009c0a3a7fb6f9
MD5 f6c652743a5b521459e3698836bb1399
BLAKE2b-256 3e3075338a6794181944766db96daa066aa2b0cdc93eaf2aca7aa9556d26a40d

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