Python package to plot pH diagrams
Project description
pH diagrams
A Python package to plot fractional composition diagrams and pH-log c diagrams
Installation
pip install pH-diagrams
Usage
The class Acid must be imported from ph_diagrams. To create diagrams for the acetic acid:
>>> from ph_diagrams import Acid >>> import matplotlib.pyplot as plt >>> fig, axs = plt.subplots(nrows=1, ncols=2) >>> acetic_acid = Acid(pKa=(4.76,), acid_concentration=0.1) >>> acetic_acid.plot(plot_type='distribution', backend='matplotlib', title='Acetic acid - Distribution diagram', ax=axs[0], legend=False) >>> acetic_acid.plot(plot_type='pC', backend='matplotlib', title='Acetic acid - pH-log c diagram', ax=axs[1]) >>> plt.show()
As can be seen, the parameter pKa must be a tuple even if there is only one value. The above example generates the following plot, with both diagrams side by side:
The plots above were made with Matplotlib, the default backend.
Changing the backend parameter to plotly, and removing the ax parameter (it works only with Matplotlib), will open a browser window for each plot. Since Plotly is interactive, the user can zoom, pan, and see values on hover.
For more basic usage examples, see the tutorial.ipynb notebook on notebooks folder. In the same folder, the tutorial_interactive_ipywidgets.ipynb file shows how to use ipywidgets to create interactive diagrams.
Full documentation is hosted on Read the Docs.
A live interactive version of this project can be seen clicking in the following badge:
The web app was made with Streamlit and hosted on Heroku.
A local version of the Streamlit app can be used running the command streamlit-ph on a terminal after installing the package. A browser window will open (if not, follow the instructions shown on the terminal output).
A brief explanation on the chemical theory behind each diagram can be seen here.
Contributing
All contributions are welcome.
Issues
Feel free to submit issues regarding:
recommendations
more examples for the tutorial
enhancement requests and new useful features
code bugs
Pull requests
before starting to work on your pull request, please submit an issue first
fork the repo
clone the project to your own machine
commit changes to your own branch
push your work back up to your fork
submit a pull request so that your changes can be reviewed
For full contribution guidelines and details check out our contributing guide.
Citing
If you use this project in a scientific publication or in classes, please consider citing as
F. L. S. Bustamante & H. B. Soares & N. O. Souza, pH diagrams, 2021. Available at: https://github.com/chicolucio/pH-diagrams
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
Hashes for pH_diagrams-0.3.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f60fa4967d3791ad981f7505669ddbcc9dfa7e345e885dba437bbdb301e453a9 |
|
MD5 | 1ef7a2117fcb79b89747f4b1450e6933 |
|
BLAKE2b-256 | bbe496d7c06b12629cde328c42b632963f360765c620ae0ae230c83379e0b20a |