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
parent 83de77387d
commit 1c54f0c65c
No known key found for this signature in database
GPG Key ID: 06E88726998AB3C7
4 changed files with 17690 additions and 0 deletions

17635
grafik/heatmap/faust.txt Normal file

File diff suppressed because it is too large Load Diff

BIN
grafik/heatmap/heatmap.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

55
grafik/heatmap/heatmap.py Executable file
View 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')

BIN
grafik/heatmap/neo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB