Tuesday, September 27, 2016

Python: Matplotlib: Scatter Plot Example

Noteworthy:

# "Random values in a given shape."
numpy.random.rand(d0, d1, ..., dn)

# "Make a scatter plot of x vs y, where x and y are sequence like objects of the same length."
matplotlib.pyplot.scatter(x, y, s=20, c=None, marker='o', cmap=None, norm=None, vmin=None, vmax=None, alpha=None, linewidths=None, verts=None, edgecolors=None, hold=None, data=None, **kwargs)


Command:

$ cat testscatterplot.py


Result:

#!/usr/local/bin/python

import matplotlib.pyplot as plt
from numpy.random import rand
a = rand(100)
b = rand(100)
plt.scatter(a,b)
plt.show()


Command:

$ python testscatterplot.py


Graphical output: