/
vis.py
77 lines (54 loc) · 2.89 KB
/
vis.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import streamlit as st
import pandas as pd
import plotly.express as px
import plotly.figure_factory as ff
import numpy as np
from wordcloud import WordCloud
import matplotlib.pyplot as plt
data = pd.read_json("data/DDCall.json")
#data = pd.read_excel("data/DDCall.xlsx")
dnbcolor = ['#FEFEFE', '#2499ff', '#f33930', '#b6c73f', '#ffd44d',
'#3cb8f6', '#f9852e', '#e3d98f', '#000000', '#01be00']
testcolor = ['#ff6900', '#fcb900', '#7bdcb5', '#00d084', '#8ed1fc',
'#0693e3', '#abb8c3', '#eb144c', '#f78da7', '#9900ef']
alldata = data['found'].sum(axis=0)
st.header("Darstellung der Sammlungen der DNB")
st.write("Informationen zu Datengrundlage: Die die erstellten Visualisieurungen basieren auf den Titeldaten der DNB. Hierfür wurde für jede DDC-Sachgruppe "
"eine Suchanfrage über die SRU-Schnittstelle gestellt und die erhaltene Treffermenge übernommen.")
st.write("Abgebildete Titeldaten:", alldata)
st.write("Stand der Daten: 21.03.2022")
st.subheader("Unsere Sammlungen:")
st.info("INFO: Klicken Sie auf die einzelnen Elemente, um eine detailliertere Darstellung der Teilmengen sehen zu können. "
"Bewegen Sie Ihren Cursor auf die Elemente, um Zusatzinformationen zu erhalten." )
#Erster Darstellung:
fig = px.sunburst(data, path=['Parent_title', 'DDCsecond-title', 'Sachgebiet'], values='found',
custom_data=['Parent_title', 'found', 'Parent_no'],
height=1000, color_discrete_sequence = testcolor)
fig.update_traces(insidetextorientation='radial', texttemplate="%{label}<br>%{percentEntry:.2%}",
hovertemplate="<br>".join([
"DDC-Sachgruppe: %{label}",
"Anzahl: %{customdata[1]}",
"Anteil: %{percentEntry:.2%}",
"DDC-Hauptklasse: %{customdata[2]} - %{customdata[0]}"]),
sort=False,
rotation=180,
textfont_size=12
)
st.plotly_chart(fig, use_container_width=True)
st.subheader("Darstellung Sachgruppen DDC 2")
fig2 = px.sunburst(data, path=['Parent_title','Sachgebiet'], values='found',
color='found', hover_data=['Sachgebiet'],
color_continuous_scale='YlGn',
#color_continuous_midpoint=np.average(data['Parent_no'], weights=data['Results']),
height=800)
fig2.update_traces(insidetextorientation='radial')
st.plotly_chart(fig2, use_container_width=True)
st.subheader("Wordcloud")
ddcdata = data.set_index('Parent_title').to_dict()['found']
worddata = data.set_index('Sachgebiet').to_dict()['found']
wc = WordCloud(background_color="white").generate_from_frequencies(ddcdata)
wc2 = WordCloud(background_color="white", width=800, height=400).generate_from_frequencies(worddata)
fig6, ax = plt.subplots()
ax.imshow(wc2, interpolation="bilinear")
ax.axis("off")
st.pyplot(fig6)