Time Country: Matplotlib Pyplot PLT Numpy NP Matplotlib Pyplot PLT Sklearn SVM Sklearn Datasets
Time Country: Matplotlib Pyplot PLT Numpy NP Matplotlib Pyplot PLT Sklearn SVM Sklearn Datasets
pyplot as plt
import numpy as np
import matplotlib.pyplot as plt
from sklearn import svm
from sklearn.datasets import make_blobs
time = [2020, 2019, 2018, 2017, 2016, 2015, 2014, 2013, 2012,
2011]
country = [
['Belgium', 862, 876, 0, 0, 1054, 949, 889, 715, 755, 636],
['Denmark', 1261, 1351, 0, 0, 1552, 1462, 1377, 1341, 1406, 1574],
['United Kingdom', 11990, 12061, 0, 0, 13876, 14867, 15196, 14972,
15370, 15343],
['Germany', 42260, 46632, 0, 0, 48480, 47384, 48154, 47353, 46620,
46986],
['France', 12771, 14103, 0, 0, 14206, 14306, 14500, 14690, 14540,
14655],
['Ireland', 75, 58, 0, 0, 202, 250, 263, 333, 492, 494],
['Italy', 10061, 9229, 0, 0, 8848, 0, 8601, 8307, 8439, 8794],
['Luxembourg', 129, 117, 0, 0, 143, 128, 128, 113, 109, 85],
['Netherlands', 2198, 2228, 0, 0, 2290, 2207, 2294, 2315, 2375,
2585],
['Greece', 400, 356, 0, 0, 606, 550, 651, 698, 628, 721],
['Portugal', 695, 703, 0, 0, 724, 925, 722, 647, 621, 571],
['Spain', 1431, 1288, 0, 0, 2745, 2799, 2953, 3026, 3266, 3430],
['Albania', 0, 4, 0, 0, 21, 14, 10, 0, 0, 3],
['Andorra', 3, 3, 0, 0, 0, 0, 0, 0, 0, 0],
['Austria', 2124, 2066, 0, 0, 2078, 2205, 2092, 2162, 2258, 2154],
['Bulgaria', 239, 186, 0, 0, 230, 280, 218, 282, 245, 262],
['Finland', 1588, 1321, 0, 0, 1260, 1289, 1419, 1596, 1698, 1650],
['Hungary', 428, 427, 0, 0, 616, 569, 546, 642, 692, 662],
['Iceland', 44, 47, 0, 0, 35, 40, 51, 33, 37, 50],
['Malta', 6, 5, 2, 5, 3, 9, 5, 13, 11, 9],
['Monaco', 6, 10, 0, 0, 7, 5, 6, 5, 4, 6],
['Norway', 880, 957, 0, 0, 1227, 1153, 1106, 1101, 1009, 1122],
['Poland', 4010, 3887, 0, 0, 4261, 4676, 3941, 4237, 4410, 3879],
['Romania', 817, 881, 0, 0, 1005, 975, 952, 993, 1022, 1424],
['San Marino', 9, 11, 0, 0, 4, 7, 4, 11, 0, 0],
['Sweden', 1764, 1802, 0, 0, 2032, 2038, 1984, 2332, 2288, 2004],
['Switzerland', 1384, 1369, 0, 0, 1462, 1477, 1480, 1525, 1480,
1597],
['Estonia', 21, 31, 0, 0, 29, 30, 44, 25, 20, 62],
['Latvia', 93, 82, 0, 0, 95, 136, 103, 225, 193, 173],
['Lithuania', 95, 90, 0, 0, 95, 101, 123, 117, 109, 93],
['Georgia', 81, 85, 0, 0, 96, 99, 110, 114, 139, 138],
['Armenia', 63, 112, 0, 0, 125, 113, 121, 125, 137, 121],
['Azerbaijan', 90, 147, 0, 0, 144, 184, 168, 156, 144, 193],
['Belarus', 317, 298, 0, 0, 455, 543, 652, 1489, 1681, 1725],
['Moldova', 85, 85, 0, 0, 91, 64, 67, 67, 93, 97],
['Russian Federation', 23759, 23337, 0, 0, 26795, 29269, 24072,
28765, 28701, 26495],
['Ukraine', 1361, 2097, 0, 0, 2233, 2271, 2457, 2856, 2491, 2649],
['Slovenia', 0, 0, 0, 0, 0, 0, 0, 0, 0, 470],
['Croatia', 117, 195, 0, 0, 175, 169, 170, 230, 217, 230],
['Czechia', 673, 765, 0, 0, 792, 880, 910, 984, 867, 783],
['Slovakia', 206, 206, 0, 0, 220, 228, 211, 184, 168, 224],
['North Macedonia', 0, 0, 0, 0, 0, 0, 0, 42, 50, 37],
['Bosnia and Herzegovina', 50, 45, 0, 0, 192, 0, 41, 7, 2, 43],
['Serbia', 138, 168, 0, 0, 178, 178, 202, 201, 192, 180],
['Montenegro', 5, 16, 0, 0, 10, 23, 13, 23, 37, 20]]
fig, ax = plt.subplots()
choose = input()
ax.set_title("The scatterplot of amount and time")
if choose != "0":
for i in country:
if i[0] == choose:
useless = i.pop(0)
y_axis = i
x_axis = time
for j in range(len(y_axis),0,-1):
if j < len(y_axis):
if y_axis[j] == 0:
del y_axis[j]
del x_axis[j]
ax.scatter(x_axis, y_axis, color='blue', label='New
Points')
else:
y_axis = []
x_axis = []
for i in country:
for j in range(1,len(i)):
y_axis.append(i[j])
for k in range(len(time)):
x_axis.append(time[k])
for j in range(len(y_axis),0,-1):
if j < len(y_axis):
if y_axis[j] == 0:
del y_axis[j]
del x_axis[j]
ax.scatter(x_axis, y_axis, color='blue', label='New Points')
ax.set_xlabel('time')
ax.set_ylabel('amount')
ax.legend()
plt.show()