Browse Source

Heatmap samt Erzeugerskript hinzugefügt.

Sie wird aus mathplotlib mit seaborn generiert.
master
hrnz 2 weeks ago
parent
commit
1c54f0c65c
No known key found for this signature in database GPG Key ID: 6E88726998AB3C7
4 changed files with 17690 additions and 0 deletions
  1. +17635
    -0
      grafik/heatmap/faust.txt
  2. BIN
      grafik/heatmap/heatmap.png
  3. +55
    -0
      grafik/heatmap/heatmap.py
  4. BIN
      grafik/heatmap/neo.png

+ 17635
- 0
grafik/heatmap/faust.txt
File diff suppressed because it is too large
View File


BIN
grafik/heatmap/heatmap.png View File

Before After
Width: 535  |  Height: 183  |  Size: 56 KiB

+ 55
- 0
grafik/heatmap/heatmap.py 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 View File

Before After
Width: 535  |  Height: 183  |  Size: 20 KiB

Loading…
Cancel
Save