Skip to main content

GeoPhylo

English | 中文

DOI CI CodeQL PyPI Python License: MIT ORCID

A geological timescale visualisation library for Matplotlib Axes. It ships the ICS (International Commission on Stratigraphy) International Chronostratigraphic Chart as reproducible, version-pinned built-in snapshots and overlays them onto time-calibrated trees — or onto any plot whose x- or y-axis is time in Ma (millions of years ago).

The R ecosystem has deeptime, which provides coord_geo() for ggplot2 and ggtree; geophylo brings the equivalent capability to the Matplotlib ecosystem. The library puts coordinate-semantics correctness and reproducibility first: whenever the coordinate semantics cannot be determined, it raises an explicit error instead of guessing silently.

Feature overview

  • Reproducible ICS data access: Timescale reads the versioned snapshots distributed with the package, covering the five core geochronologic ranks: Eon, Era, Period, Epoch and Age. Snapshots preserve per-boundary ~ approximate values, quantitative uncertainties (±), and GSSP (Global Boundary Stratotype Section and Point) / GSSA (Global Standard Stratigraphic Age) definition states. Timescale(version="2024/12") opts into the historical snapshot.
  • Linear geological time axes: add_geo_axis() overlays geological time strips inside the host Axes using inset tracks, with multi-rank tracks, numeric ticks, automatic label degradation and automatic contrast colors, while guaranteeing that the host Axes' view state is left untouched.
  • Explicit coordinate contract: CoordinateSpec (with absolute_age and root_distance modes) is the single source of truth for coordinate semantics; spec_from_biophylo() builds and validates the contract from a Bio.Phylo tree.
  • Radial layout (experimental): RadialSpec + add_geo_ring() overlay a geological time ring on native polar Axes; radial_spec_from_biophylo() is the radial adapter entry point. These APIs are experimental; their signatures are not frozen.
  • Strong contract-driven exception hierarchy: every public exception inherits from GeophyloError. AmbiguousIntervalError is a subclass of IntervalNotFoundError; the inheritance is kept for compatibility with existing except clauses, so code should catch AmbiguousIntervalError before IntervalNotFoundError. See the "Exceptions and catch order" section of the user guide.

Documentation

Installation

GeoPhylo is published on PyPI: the pip install geophylo commands below resolve directly. To work from the source tree instead, install with pip install .; for a full test environment use pip install -e ".[test]".

pip install geophylo            # core (matplotlib + numpy only)
pip install "geophylo[biopython]"   # Bio.Phylo adapter
pip install "geophylo[iplotx]"      # iplotx adapter (experimental)
pip install "geophylo[pyrolite]"    # experimental read-only pyrolite backend
pip install "geophylo[test]"        # tests

Quick start: a Bio.Phylo timetree

from io import StringIO

import matplotlib.pyplot as plt
from Bio import Phylo

from geophylo import add_geo_axis, spec_from_biophylo

tree = Phylo.read(StringIO("((A:15.0, B:15.0):9.0, (C:14.0, D:14.0):10.0);"), "newick")

fig, ax = plt.subplots(figsize=(12, 8))
Phylo.draw(tree, axes=ax, do_show=False)

# root_age comes from an external time-calibration result; age_conversion
# declares the unit conversion from branch lengths to Ma.
spec = spec_from_biophylo(tree, ax, time_axis="x", age_conversion=1.0, root_age=48.0)

result = add_geo_axis(ax, spec=spec, position="bottom",
                      ranks=["Period", "Epoch"], tick_style="boundaries")
plt.tight_layout()
result.finalize()   # run once before savefig: exact label layout, then freeze
fig.savefig("timetree_with_geo.png", dpi=300)

Quick start: any Matplotlib plot (stratigraphic-column style)

import matplotlib.pyplot as plt
from geophylo import CoordinateSpec, add_geo_axis

fig, ax = plt.subplots(figsize=(12, 6))
ax.plot([0, 300], [0, 1])  # any plot content
spec = CoordinateSpec.absolute(time_axis="x", age_range=(0.0, 300.0))
result = add_geo_axis(ax, spec=spec, position="bottom", ranks=["Period"])
plt.tight_layout()
result.finalize()

The library never infers coordinate ranges on its own. The only inference entry point is CoordinateSpec.from_data_limits():

CoordinateSpec.from_data_limits(ax, mode=..., time_axis=...,
                                acknowledge_inference=True)

The default call raises CoordinateError; the caller must pass acknowledge_inference=True explicitly to acknowledge the inference.

Quick start: querying the data

from geophylo import Timescale

ts = Timescale()                              # baseline snapshot
ts.find_by_age(66.0, rank="Period").name      # 'Paleogene'
ts.get_interval("ics:period:jurassic").bounds # (older_ma, younger_ma)
list(ts.iter_intervals(ranks=["Epoch"], min_age=0, max_age=66))

Circular trees (experimental)

See examples/circular_tree.py. The tree is drawn by the user, and the tree and add_geo_ring() must share the same RadialSpec instance, so that the age at a given radius on the ring and the age at the same radius on the tree agree by construction.

Data provenance and licensing

The bundled snapshots are generated deterministically from the ICS official versioned data (CC-BY-4.0) by tools/build_snapshot.py, distributed with the package, and append-only. The machine-readable field-level diff between versions is geophylo/data/snapshots/diff-2024-12_to_2026-06.json (generated by tools/make_diff.py); per-snapshot generation logs live in tools/build-logs/; the provenance of the derived 2024/12 snapshot is documented in geophylo/data/snapshots/PROVENANCE.md.

For citation and attribution of the ICS data, see NOTICE and docs/data-policy.md. The library's source code is released under the MIT license (see LICENSE); the licenses of the third-party data files are independent of the code license.

Compatibility

  • Python 3.11–3.14; Matplotlib ≥ 3.10, < 4; NumPy ≥ 1.25.
  • The library runs headless (Agg backend). Examples are all organised as add_geo_axis() → tight_layout() → finalize() → savefig().

Stability and roadmap

  • Stable since 0.1.0: Timescale, CoordinateSpec, add_geo_axis(), GeoAxisResult and spec_from_biophylo(). The public API is unchanged in 0.2.x, which only adds opt-in keyword arguments (tick_format, track_register, fallback_truncation, min_label_gap) plus code on the public exceptions; the defaults reproduce the 0.1.x behaviour exactly.
  • Experimental, not frozen: RadialSpec, add_geo_ring(), radial_spec_from_biophylo() and spec_from_iplotx(). 0.2 does not stabilise them — signatures may still change. Stabilisation is planned for a later 0.x release, and multi-rank radial rings stay out of scope until a sound layout model exists.
  • Not planned: adapters for ETE4 or toytree (neither hands tree geometry back as a Matplotlib Axes), and online updates of the chart data.

Development

pip install -e ".[dev]"
pytest                       # full test suite (blocking gate)
pytest -m "not experimental" # stable API only
ruff check geophylo tests tools examples
mypy

The release procedure (public GitHub repository + Zenodo DOI) is described in RELEASE.md.

Author & Citation

If you use GeoPhylo in your research, please cite it (see CITATION.cff for the machine-readable citation record; concept DOI 10.5281/zenodo.23060662, version DOI 10.5281/zenodo.23060663 for v0.1.0; releases from v0.1.1 onward are archived by the Zenodo GitHub integration under concept DOI 10.5281/zenodo.23093968, version DOI 10.5281/zenodo.23093969 for v0.1.1) and, as required by the CC BY 4.0 license, cite the International Chronostratigraphic Chart separately (see NOTICE for the required attribution).

License

Source code: MIT (LICENSE). Bundled ICS chart data: CC-BY-4.0 (LICENSES/CC-BY-4.0.txt, attribution in NOTICE).

Metadata

Release files for geophylo 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for geophylo 0.2.1
File Size Uploaded Provenance Actions
geophylo-0.2.1.tar.gz 604.8 kB With provenance Details for geophylo-0.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for geophylo 0.2.1
File Interpreter ABI Platform Actions
geophylo-0.2.1-py3-none-any.whl Python 3 none any Details for geophylo-0.2.1-py3-none-any.whl

Total release size: 742.2 kB

Release files / geophylo-0.2.1.tar.gz

Download URL geophylo-0.2.1.tar.gz
Size 604.8 kB
Tags Source
SHA-256 checksum
How to use checksums
229e1a5be3de549a27551d106a72ebe46a8c2a9746962f1f93eff9b3001d712f
BLAKE2b-256 checksum
How to use checksums
5f8bb8400cd4742175b50f182025e6585e0582070911dcdbe157c55dee421c04
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 27, 2026.

Transparency log

Release files / geophylo-0.2.1-py3-none-any.whl

Download URL geophylo-0.2.1-py3-none-any.whl
Size 137.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
77f364e281396610d19523f846d5d68e2ff9053bac8c5bd96d27d36426737cfc
BLAKE2b-256 checksum
How to use checksums
6f52d12ef22e549752ffa3441d012f7422a6a5ad4f6604864d53e0a109aa1303
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 27, 2026.

Transparency log

Security for geophylo 0.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for geophylo-0.2.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 27, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page