How to make a Piper Diagram in Python - Tutorial


A Piper Diagram is an effective graphic procedure to segregate relevant analytical data to understand the sources of the dissolved constituents in water. This procedure was born under the statement that most natural waters contain cations and anions in chemical equilibrium. It is assumed that the most abundant cations are calcium (Ca), magnesium (Mg) and sodium (Na). The most common anions are bicarbonate (HCO3), sulphate (SO4) and chloride (Cl).

The Piper diagram can be made by free and commercial desktop software, however in this tutorial we have generated the Python scripts and working procedure to create a Piper Diagram from values stored in a working spreadsheet.

There are several outputs of the Piper Diagram, including a SVG format that allows further graphical editing in Inkscape. All the conversions and graphical assembly are presented on the script, so it will be much easier to modifiy for custom representation, filtering, or automated reporting.


Working files

The scripts, working spreadsheet and output folders for this tutorial can be downloaded from this link. it is recommended to place it under “My Documents” if you are working in Windows.


Saul Montoya

Saul Montoya es Ingeniero Civil graduado de la Pontificia Universidad Católica del Perú en Lima con estudios de postgrado en Manejo e Ingeniería de Recursos Hídricos (Programa WAREM) de la Universidad de Stuttgart con mención en Ingeniería de Aguas Subterráneas y Hidroinformática.

Smiley face

Subscribe to our free e-newsletter for tutorials, articles, webminars, courses and more.