Skip to content

Add matplotlib diamonds benchmark#1

Open
seisman wants to merge 2 commits into
mainfrom
bench/mpl
Open

Add matplotlib diamonds benchmark#1
seisman wants to merge 2 commits into
mainfrom
bench/mpl

Conversation

@seisman
Copy link
Copy Markdown
Member

@seisman seisman commented May 29, 2026

Summary

This PR adds the first plotting benchmark for the repository. It compares matplotlib and PyGMT using the seaborn diamonds dataset, which is large enough to make scatter plotting performance differences visible.

The benchmark:

  • loads the diamonds dataset from the seaborn example-data repository
  • makes a scatter plot
  • writes generated plot artifacts under plots/diamonds/

Example Results

python benchmarks/bench_matplotlib_diamonds.py

Two timings are reported. "Save" represents the total execution time, while "Plot" represents the execution time excluding the Figure.savefig() call.

Mode matplotlib PyGMT Ratio
Plot 0.0199s 0.0266s 0.76x
Save 0.1269s 1.0994s 0.11x
Running 10 timed run(s) per backend
Writing PNG files to plots/diamonds

Benchmarking matplotlib...
matplotlib plot mean=0.0199s median=0.0188s min=0.0179s max=0.0291s
matplotlib savefig mean=0.1269s median=0.1195s min=0.1157s max=0.1676s
Benchmarking pygmt...
pygmt plot mean=0.0266s median=0.0263s min=0.0255s max=0.0303s
pygmt savefig mean=1.0994s median=1.1031s min=1.0662s max=1.1271s

Notes:

  • It's likely unfair to compare matplotlib and pygmt "Plot" time, because matplotlib doesn't render the figure until fig.savefig is called.
  • PyGMT is slower than matplotlib, and the PS->PNG conversion by ghostscript is the slowest

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