Skip to content

Add plot module with isotherm, mixture, and selectivity plotting#2

Merged
tdpham2 merged 1 commit intomainfrom
feature/add-plot-module
Mar 17, 2026
Merged

Add plot module with isotherm, mixture, and selectivity plotting#2
tdpham2 merged 1 commit intomainfrom
feature/add-plot-module

Conversation

@tdpham2
Copy link
Copy Markdown
Owner

@tdpham2 tdpham2 commented Mar 17, 2026

Summary

  • Add a new matkit.plot module for visualizing gRASPA/RASPA simulation results with publication-quality plots
  • Support two isotherm JSON formats: single-component pressure isotherms (0.1bar_298K) and mixture RH isotherms (50_RH), with automatic format detection
  • Auto-discover adsorbate names from JSON data keys instead of hardcoding species

New Features

Plot Module (src/matkit/plot/)

  • parsers.py: JSON format auto-detection, adsorbate/selectivity key discovery, value normalization (handles string/float/NaN/Inf), collect_data_files() for directory-based loading
  • isotherm.py: plot_single_isotherm(), plot_mixture_isotherm(), plot_selectivity(), and unified plot_isotherm() with auto-dispatch
  • Multi-file overlay for comparing different MOFs or temperatures on the same axes
  • Auto-generated temperature-based legend labels (e.g. "273 K", "293 K") when overlaying single-component isotherms
  • Pretty LaTeX-style labels for 15 common adsorbates (CO2 → CO$_2$, etc.)

CLI Commands

matkit plot isotherm   --data <file> [--data-dir <dir>] [--output] [--dpi] [--log-x] [--adsorbate] ...
matkit plot selectivity --data <file> [--output] [--dpi] [--log-y] ...

Key Options

  • --data (multiple) / --data-dir: load files individually or scan a directory
  • --adsorbate: filter which species to plot in mixture data
  • --label: custom legend labels per file
  • --log-x / --log-y: logarithmic axis scales
  • --no-errorbars: omit error bars
  • --figsize, --dpi, --fontsize-*: full control over figure appearance

Dependencies

  • matplotlib>=3.5 added as optional dependency under [plot] extra (pip install matkit[plot])

Tests

  • 72 new tests covering parsers (format detection, value normalization, NaN handling, adsorbate discovery), plot output (file creation, format validation, multi-file overlay), and CLI (help text, end-to-end commands, --data-dir)
  • All 114 tests pass (42 existing + 72 new), zero regressions

Add a new matkit.plot module for visualizing simulation results:

- parsers.py: auto-detect JSON format (single-component pressure
  isotherms vs mixture RH isotherms), auto-discover adsorbate names
  from data keys, normalize string/float values, handle NaN/Inf
- isotherm.py: plot_single_isotherm, plot_mixture_isotherm,
  plot_selectivity, and unified plot_isotherm with auto-detection
- Support multi-file overlay for comparing MOFs or temperatures,
  with auto-generated temperature labels (e.g. '273 K')
- --data-dir option to load all JSON files from a directory
- Pretty LaTeX labels for common adsorbates (CO2, N2, H2O, etc.)
- CLI: matkit plot isotherm / matkit plot selectivity with options
  for DPI, figsize, log scale, error bars, fonts, custom labels
- matplotlib is an optional dependency: pip install matkit[plot]
- 72 new tests covering parsers, plotting, and CLI commands
@tdpham2 tdpham2 merged commit 7026bcf into main Mar 17, 2026
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant