October 8, 2021

Python - simple graphics

I have the latest Python (3.9.7) installed, but I try a tiny graphics demo and find that numpy and matplotlib are not installed. Missing packages are installed using the "pip" utility which you get as part of the python you installed.

I type at the "git bash" window:

pip install numpy
pip install matplotlib
After installing these 2 packages, voila! I can run a trivial graphics demo via:
python plot.py
Where plot.py is:
#! /usr/bin/python
import numpy as np
import matplotlib.pyplot as plt

N = 50
x = np.random.rand(N)
y = np.random.rand(N)

plt.scatter(x, y)
plt.show()
This is quite nice as it demonstrates that I can use the python matplotlib library for graphics and that my github setup is working just fine.
Feedback? Questions? Drop me a line!

Tom's Mineralogy Info / [email protected]