Publication-quality reaction energy diagrams for computational chemistry
Project description
chemdiagrams
A Python package for creating publication-quality reaction energy diagrams with Matplotlib.
Installation
You can use the latest release by installing it from PyPi:
pip install chemdiagrams
Requirements: Python ≥ 3.10, Matplotlib ≥ 3.7, NumPy ≥ 1.23, SciPy ≥ 1.10
Features
- Multiple reaction paths on a single diagram
- Nine connector styles: dotted, solid, broken dotted, broken solid, spline dotted, spline solid, broken spline dotted, broken spline solid or none
- Five diagram styles:
open,halfboxed,boxed,twosided,borderless - Automatic, stacked, naïve, and averaged energy label placement (numbering)
- Custom text labels for each path at each position
- Energy difference bars with optional whiskers
- Axis break markers for both x and y axes
- Image placement along the diagram, with automatic collision avoidance and pixel-accurate scaling options
- Full access to the underlying Matplotlib objects for fine-grained customisation
- Customizable templates for consistent styling across multiple diagrams
- Possibility to insert multiple diagrams into a single figure using external Matplotlib axes (e.g. plt.subplots)
Documentation
Full documentation with usage instructions, examples, and API reference is available at https://tonner-zech-group.github.io/chem-diagrams/.
Quickstart
Drawing paths
from chemdiagrams import EnergyDiagram
dia = EnergyDiagram()
dia.draw_path(
x_data=[0, 1, 2, 3, 4, 5],
y_data=[0, -13, 22, 75, 39, 20],
color="blue",
path_name="Pathway A",
linetypes=[2, 3, 4, -1, 0],
)
dia.draw_path(
x_data=[0, 1, 2, 3, 5],
y_data=[0, -25, 20, 50, 6],
color="red",
path_name="Pathway B",
)
dia.legend(fontsize=7)
dia.add_numbers_auto()
dia.set_xlabels(["A", "B", "C", "D", "E", "F"])
dia.ax.set_ylabel("Energy / kJ mol$^{-1}$", fontsize=8)
dia.show()
Connector styles (linetypes): 0 none, 1 dotted (default), -1 dotted with gap, 2 solid, -2 solid with gap, 3 dotted spline, -3 dotted spline with gap, 4 solid spline, -4 solid spline with gap. A single integer applies the same style to all segments.
Diagram styles
dia = EnergyDiagram(style="halfboxed") # open | halfboxed | boxed | twosided | borderless
Energy labels
dia.add_numbers_auto() # recommended
dia.add_numbers_stacked()
dia.add_numbers_naive()
dia.add_numbers_average()
Energy difference bars
dia.draw_difference_bar(
x=3,
y_start_end=(-25, 0),
description=r"$\Delta E_\mathrm{R}$: ",
x_whiskers=(5, 0),
left_side=True,
)
Images
dia.add_image_series_in_plot(
["img0.png", "img1.png", "img2.png", "img3.png", "img4.png"],
y_placement="auto",
width=0.6,
proportional_scaling=True,
)
Saving figures
dia.fig.savefig("diagram.png", dpi=300, bbox_inches="tight")
dia.fig.savefig("diagram.pdf", bbox_inches="tight")
For full documentation on all parameters and features, see https://tonner-zech-group.github.io/chem-diagrams/.
Examples
Examples can be found in the (documentation). A set of even more examples is available in examples/example_use.ipynb. The latter, however, is not actively maintained anymore and may be outdated with respect to the latest version of the package.
Citation
If you use chemdiagrams in published work, please consider citing the repository:
Tim Bastian Enders, chemdiagrams, https://github.com/Tonner-Zech-Group/chem-diagrams, https://doi.org/10.5281/zenodo.18957965
License
MIT — see LICENSE for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file chemdiagrams-0.5.5.tar.gz.
File metadata
- Download URL: chemdiagrams-0.5.5.tar.gz
- Upload date:
- Size: 61.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8aeffdc353fd86dc45ce5ac49a96f971ad084e8a6c995523917beaaa9b855813
|
|
| MD5 |
ad8580af51266ddea27669cb85935092
|
|
| BLAKE2b-256 |
58875804ed1e93d1e5d6088dc317566e27f85a315099f1321af1cf58fb1006c3
|
Provenance
The following attestation bundles were made for chemdiagrams-0.5.5.tar.gz:
Publisher:
publish.yml on Tonner-Zech-Group/chem-diagrams
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
chemdiagrams-0.5.5.tar.gz -
Subject digest:
8aeffdc353fd86dc45ce5ac49a96f971ad084e8a6c995523917beaaa9b855813 - Sigstore transparency entry: 1667832511
- Sigstore integration time:
-
Permalink:
Tonner-Zech-Group/chem-diagrams@0b3af0c15f4c01faa3ae54dd84743cd4a9ed42fc -
Branch / Tag:
refs/tags/v0.5.5 - Owner: https://github.com/Tonner-Zech-Group
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@0b3af0c15f4c01faa3ae54dd84743cd4a9ed42fc -
Trigger Event:
push
-
Statement type:
File details
Details for the file chemdiagrams-0.5.5-py3-none-any.whl.
File metadata
- Download URL: chemdiagrams-0.5.5-py3-none-any.whl
- Upload date:
- Size: 51.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e13fb15317c67f016a46c6ec8d1ae6843919bcd1ac7943237d5318938d4f84d0
|
|
| MD5 |
f303c171f397ee3e0db89eafffe59698
|
|
| BLAKE2b-256 |
23e8bd8dfda1c1f8b148fdf38279f7d2d5c6dc1a09b2e1abfa40313a40868efb
|
Provenance
The following attestation bundles were made for chemdiagrams-0.5.5-py3-none-any.whl:
Publisher:
publish.yml on Tonner-Zech-Group/chem-diagrams
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
chemdiagrams-0.5.5-py3-none-any.whl -
Subject digest:
e13fb15317c67f016a46c6ec8d1ae6843919bcd1ac7943237d5318938d4f84d0 - Sigstore transparency entry: 1667832983
- Sigstore integration time:
-
Permalink:
Tonner-Zech-Group/chem-diagrams@0b3af0c15f4c01faa3ae54dd84743cd4a9ed42fc -
Branch / Tag:
refs/tags/v0.5.5 - Owner: https://github.com/Tonner-Zech-Group
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@0b3af0c15f4c01faa3ae54dd84743cd4a9ed42fc -
Trigger Event:
push
-
Statement type: