Heatmap samt Erzeugerskript hinzugefügt.

Sie wird aus mathplotlib mit seaborn generiert.
This commit is contained in:
hrnz 2020-11-08 18:18:45 +01:00
父節點 83de77387d
當前提交 1c54f0c65c
沒有發現已知的金鑰在資料庫的簽署中
GPG 金鑰 ID: 06E88726998AB3C7
共有 4 個檔案被更改,包括 17690 行新增0 行删除

17635
grafik/heatmap/faust.txt Normal file

檔案差異因為檔案過大而無法顯示 載入差異

二進制
grafik/heatmap/heatmap.png Normal file

未顯示二進位檔案。

之後

寬度:  |  高度:  |  大小: 56 KiB

55
grafik/heatmap/heatmap.py Executable file
查看文件

@ -0,0 +1,55 @@
#!/usr/bin/env python
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
import seaborn as sns
f = open("faust.txt", "r")
str = f.read()
LAYOUT = ["xvlcwkhgfqß","uiaeosnrtdy","üöäpzbm,.j"]
#LAYOUT = ["qwertzuiopü","asdfghjklöö","yxcvbnm;:-"]
# we create two vertically offset data points for each key
# to visually vertically stretch the result
d = {}
for i in range(len(LAYOUT[0])):
x = LAYOUT[0][i]
X = x.upper()
d[x] = [(73+i*36), (62-10),0]
d[X] = [(73+i*36), (62+0),0]
for i in range(len(LAYOUT[1])):
x = LAYOUT[1][i]
X = x.upper()
d[x] = [(84+i*36), (98-10),0]
d[X] = [(84+i*36), (98+0),0]
for i in range(len(LAYOUT[2])):
x = LAYOUT[2][i]
X = x.upper()
d[x] = [(101+i*36), (134-10),0]
d[X] = [(101+i*36), (134+0),0]
for x in str:
x = x.lower()
X = x.upper()
if x in d.keys():
d[x][2] += 1
d[X][2] += 1
df = pd.DataFrame.from_dict(d, orient="index", columns=["x","y","z"])
fig = plt.figure(figsize=(5.35, 1.83), dpi=100)
ax= fig.add_axes([0,0,1,1])
img = mpimg.imread("neo.png")
sns.kdeplot(data=df, x="x",y="y",weights="z",
cmap='rainbow', fill=True, alpha=1,
bw_adjust=0.5, thresh=0,
cut=800, clip=((0,535),(0,183)),
levels=1000)
ax.imshow(img, alpha=0.4, zorder=5)
ax.axes.get_xaxis().set_visible(False)
ax.axes.get_yaxis().set_visible(False)
ax.set_frame_on(False)
ax.axis('off')
plt.savefig('heatmap.png')

二進制
grafik/heatmap/neo.png Normal file

未顯示二進位檔案。

之後

寬度:  |  高度:  |  大小: 20 KiB