repl.it
@justinholman/

SimpleGraphs

Python

use matplotlib

fork
loading
Files
  • main.py
  • scatter-test.png
  • scatter0.png
  • scatter1.png
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import matplotlib as mpl
# this use('Agg') part is what allows us to create graphics 
mpl.use('Agg')

import matplotlib.pyplot as plt

# Just some random data
x = [1470,5292,7622,6080,5049,9706,3905,6273,432]
y = [1842,6140,5069,5358,5684,11122,4324,7047,855]

# create a scatter plot with labels and a title
plt.scatter(x,y)
plt.xlabel("x axis")
plt.ylabel("y axis")
plt.title("Scatter Plot Example")
plt.show()

# this generates the file - you may need to refresh to see the file
plt.savefig('scatter-test.png')
plt.clf()
print("Shadoobie ... scatter, scatter")