×
Help
General
Physics Plot Gallery (PPG) is a simple HTML5 javascript-application for running
matplotlib scripts in the browser.
The purpose of PPG is to provide a gallery where matplotlib scripts are stored that can
be easily modified and shown in physics classes. Of course these scripts also run
in any
Python environment
where matplotlib is installed. The complete gallery can be
downloaded
from GitHub as a zip-file.
Getting started
- Select a convenient graph from the gallery.
- Modify the Python script to your needs.
- Press Run to execute the script.
- Download the graph in pdf, png or svg format.
- Do not forget to save your script using
Download script
button.
- Next time you can upload your script directly.
- Do you have a nice matplotlib script? Send it to me.
Hash link
When you have your own matplotlib scripts on a webserver (e.g. on GitHub), you can
open this script directly on PPG with a direct link using the hash function. This way
you can easily share your script with others. The direct link would be for instance:
https://jeroenvantilburg.nl/ppg/#https://www.example.com/test.py
Keep in mind that you teh webserver has to set
Access-Control-Allow-Origin
due to the CORS-policy on most browsers.
You can also host your python scripts on your own Github Pages when you have a
Github account. This way you will bypass any
CORS restriction. The direct link would then be:
https://jeroenvantilburg.nl/ppg/#https://myname.github.io/myproject/test.py
Technology
The Python script is interpreted by the
Pyodide engine.
Pyodide is a Python distribution for the browser which is built using the
WebAssembly/
Emscripten compiler. This means that
the full Python interpreter runs directly (locally) in the
browser.
The main drawback of running Python through the browser is the
lack of a generic graphical backend. This means that any graphical output has to be
fetched from the Pyodide side and placed on the website when the Python script has finished.
For this reason PPG puts some minimal requirements on the Python scripts. Namely that
each script has to start with
import matplotlib.pyplot as plt
and end
with
plt.show()
.
Security/privacy
No data leaves your computer by using this website. All analysis is done locally on your own
computer. This is a cookie-free website.
Webapp compatibility
PPG does not run yet on all mobile devices. PPG does not work in Internet Explorer.
In case you are still using IE, please
consider moving to a modern browser like Chrome, Edge, Firefox or Safari.
Source code
The source code from this website is freely available on
GitHub under the free
Unlicense. The source code
may be freely copied and hosted on every web server. Please make sure to keep the code
up-to-date since new updates and bug fixes may come out.
Feedback and questions
To keep this website as user-friendly as possible I depend on your feedback. Please send your
questions, improvements, bug reports, suggestions, comments and compliments
to
.
Acknowledgments
Many thanks to
GitHub and
GitHub Pages for hosting PPG.
PPG depends on the following useful javascript libraries:
Other applications
Besides PPG, there are a number of other, third-party applications that can be used
to run Matplotlib scripts. Select the application that suits your needs.
- Iodide is a notebook-like environment for
literate scientific computing and communication for the web. It is no longer actively
maintained. Historically, Pyodide started as plugin for iodide.
- JupyterLite
is a JupyterLab distribution that runs entirely in the browser, based on Pyodide.