-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path12_28_nanjing_co.py
30 lines (30 loc) · 1.11 KB
/
12_28_nanjing_co.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import xlrd
from sklearn.manifold import TSNE
import matplotlib.pyplot as plt
import numpy as np
from mpl_toolkits.mplot3d import Axes3D
from matplotlib import font_manager
wb = xlrd.open_workbook('D:/12_25_topic_co/03-17_04-26.xlsx')
sh = wb.sheet_by_name('Sheet1')
my_font = font_manager.FontProperties(fname="C:/Windows/Fonts/simsun.ttc")
final_result = []
for i in range(1, 11):
array = []
for j in range(1, 11):
array.append(sh.cell(i, j).value)
final_result.append(array)
vectors = TSNE(n_components=3, learning_rate=200).fit_transform(final_result)
print(vectors)
x = []
y = []
z = []
for vector in vectors:
x.append(vector[0])
y.append(vector[1])
z.append(vector[2])
ax1 = plt.axes(projection='3d')
ax1.plot3D(x, y, z, '*')
text = ['疫情中的众生相', '防控部署', '医疗物资保障与基础设施建设', '疫情中的经济', '疫情中的文化传播', '疫情中的民生', '新冠肺炎医治', '疫情中的国际社会', '新冠疫情动态', '疫情中的法制']
for i in range(len(x)):
ax1.text(x[i], y[i], z[i], text[i], fontsize=12, fontproperties=my_font)
plt.show()