Verbesserungen: Visualierungen und Achsenbeschriftung
This commit is contained in:
@ -25,7 +25,7 @@ import re
|
|||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
export_fig_visual = False # Expot der Visualsierungen gesamt
|
export_fig_visual = False # Expot der Visualsierungen gesamt
|
||||||
theme = "dark" # Optionen: "dark" oder "light"
|
theme = "light" # Optionen: "dark" oder "light"
|
||||||
|
|
||||||
# Template
|
# Template
|
||||||
from ci_template import plotly_template
|
from ci_template import plotly_template
|
||||||
@ -119,7 +119,6 @@ def calculate_sample_size(N, Z=1.96, p=0.5, e=0.05):
|
|||||||
n = n_0 / (1 + ((n_0 - 1) / N))
|
n = n_0 / (1 + ((n_0 - 1) / N))
|
||||||
return math.ceil(n)
|
return math.ceil(n)
|
||||||
|
|
||||||
# Visualisierung 1: Netzwerkanalyse
|
|
||||||
# Visualisierung 1: Netzwerkanalyse
|
# Visualisierung 1: Netzwerkanalyse
|
||||||
def visualize_network(bib_database):
|
def visualize_network(bib_database):
|
||||||
search_terms = {
|
search_terms = {
|
||||||
@ -303,6 +302,8 @@ def visualize_network(bib_database):
|
|||||||
else:
|
else:
|
||||||
marker_style = dict(color=color)
|
marker_style = dict(color=color)
|
||||||
marker_style['size'] = [n['size'] for n in nodes]
|
marker_style['size'] = [n['size'] for n in nodes]
|
||||||
|
# Erhöhe Kontrast Marker-Rand zum Hintergrund
|
||||||
|
marker_style['line'] = {'width': 1, 'color': colors['background']}
|
||||||
return go.Scatter(
|
return go.Scatter(
|
||||||
x=[n['x'] for n in nodes],
|
x=[n['x'] for n in nodes],
|
||||||
y=[n['y'] for n in nodes],
|
y=[n['y'] for n in nodes],
|
||||||
@ -312,7 +313,7 @@ def visualize_network(bib_database):
|
|||||||
hoverinfo='text',
|
hoverinfo='text',
|
||||||
marker=marker_style,
|
marker=marker_style,
|
||||||
textposition="top center",
|
textposition="top center",
|
||||||
textfont=dict(size=10, color=colors['white']),
|
textfont=dict(size=12, color=colors['text']),
|
||||||
name=name
|
name=name
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -326,11 +327,14 @@ def visualize_network(bib_database):
|
|||||||
x_title="Technologische Dimension",
|
x_title="Technologische Dimension",
|
||||||
y_title="Pädagogische Dimension"
|
y_title="Pädagogische Dimension"
|
||||||
)
|
)
|
||||||
layout["margin"] = dict(b=20, l=5, r=5, t=40)
|
layout["margin"] = dict(b=160, l=5, r=5, t=40)
|
||||||
layout["hovermode"] = "closest"
|
layout["hovermode"] = "closest"
|
||||||
|
layout["font"] = {"size": 14, "color": colors['text']}
|
||||||
|
layout["title"] = {"font": {"size": 16}}
|
||||||
|
layout["autosize"] = True
|
||||||
fig.update_layout(**layout)
|
fig.update_layout(**layout)
|
||||||
|
|
||||||
fig.show()
|
fig.show(config={"responsive": True})
|
||||||
export_figure(fig, "visualize_network", export_fig_visualize_network, bib_filename)
|
export_figure(fig, "visualize_network", export_fig_visualize_network, bib_filename)
|
||||||
|
|
||||||
# Einfache Pfadanalyse nach dem Anzeigen der Figur
|
# Einfache Pfadanalyse nach dem Anzeigen der Figur
|
||||||
@ -423,11 +427,19 @@ def visualize_tags(bib_database):
|
|||||||
text_auto=True
|
text_auto=True
|
||||||
)
|
)
|
||||||
|
|
||||||
fig.update_layout(**get_standard_layout(
|
layout = get_standard_layout(
|
||||||
title=fig.layout.title.text,
|
title=fig.layout.title.text,
|
||||||
x_title='Tag',
|
x_title='Tag',
|
||||||
y_title='Anzahl der Vorkommen'
|
y_title='Anzahl der Vorkommen'
|
||||||
))
|
)
|
||||||
|
layout["font"] = {"size": 14, "color": colors['text']}
|
||||||
|
layout["title"] = {"font": {"size": 16}}
|
||||||
|
layout["margin"] = dict(b=160, t=60, l=40, r=40)
|
||||||
|
layout["xaxis"] = layout.get("xaxis", {})
|
||||||
|
layout["xaxis"]["tickangle"] = -45
|
||||||
|
layout["xaxis"]["automargin"] = True
|
||||||
|
layout["autosize"] = True
|
||||||
|
fig.update_layout(**layout)
|
||||||
|
|
||||||
fig.show(config={"responsive": True})
|
fig.show(config={"responsive": True})
|
||||||
export_figure(fig, "visualize_tags", export_fig_visualize_tags, bib_filename)
|
export_figure(fig, "visualize_tags", export_fig_visualize_tags, bib_filename)
|
||||||
@ -463,11 +475,19 @@ def visualize_index(bib_database):
|
|||||||
print(tabulate(index_data, headers="keys", tablefmt="grid"))
|
print(tabulate(index_data, headers="keys", tablefmt="grid"))
|
||||||
|
|
||||||
fig = px.bar(index_data, x='Index', y='Count', title=f'Relevanzschlüssel nach Indexkategorien (n={total_count}, Stand: {current_date})', labels={'Index': 'Index', 'Count': 'Anzahl der Vorkommen'}, text_auto=True)
|
fig = px.bar(index_data, x='Index', y='Count', title=f'Relevanzschlüssel nach Indexkategorien (n={total_count}, Stand: {current_date})', labels={'Index': 'Index', 'Count': 'Anzahl der Vorkommen'}, text_auto=True)
|
||||||
fig.update_layout(**get_standard_layout(
|
layout = get_standard_layout(
|
||||||
title=fig.layout.title.text,
|
title=fig.layout.title.text,
|
||||||
x_title='Index',
|
x_title='Index',
|
||||||
y_title='Anzahl der Vorkommen'
|
y_title='Anzahl der Vorkommen'
|
||||||
))
|
)
|
||||||
|
layout["font"] = {"size": 14, "color": colors['text']}
|
||||||
|
layout["title"] = {"font": {"size": 16}}
|
||||||
|
layout["margin"] = dict(b=160, t=60, l=40, r=40)
|
||||||
|
layout["xaxis"] = layout.get("xaxis", {})
|
||||||
|
layout["xaxis"]["tickangle"] = -45
|
||||||
|
layout["xaxis"]["automargin"] = True
|
||||||
|
layout["autosize"] = True
|
||||||
|
fig.update_layout(**layout)
|
||||||
fig.update_traces(marker=plot_styles['balken_primaryLine'])
|
fig.update_traces(marker=plot_styles['balken_primaryLine'])
|
||||||
fig.show(config={"responsive": True})
|
fig.show(config={"responsive": True})
|
||||||
export_figure(fig, "visualize_index", export_fig_visualize_index, bib_filename)
|
export_figure(fig, "visualize_index", export_fig_visualize_index, bib_filename)
|
||||||
@ -504,11 +524,19 @@ def visualize_research_questions(bib_database):
|
|||||||
print(tabulate(rq_data, headers="keys", tablefmt="grid"))
|
print(tabulate(rq_data, headers="keys", tablefmt="grid"))
|
||||||
|
|
||||||
fig = px.bar(rq_data_df, x='Research_Question', y='Count', title=f'Zuordnung der Literatur zu Forschungsunterfragen (n={total_count}, Stand: {current_date})', labels={'Research_Question': 'Forschungsunterfrage', 'Count': 'Anzahl der Vorkommen'}, text_auto=True)
|
fig = px.bar(rq_data_df, x='Research_Question', y='Count', title=f'Zuordnung der Literatur zu Forschungsunterfragen (n={total_count}, Stand: {current_date})', labels={'Research_Question': 'Forschungsunterfrage', 'Count': 'Anzahl der Vorkommen'}, text_auto=True)
|
||||||
fig.update_layout(**get_standard_layout(
|
layout = get_standard_layout(
|
||||||
title=fig.layout.title.text,
|
title=fig.layout.title.text,
|
||||||
x_title='Forschungsunterfrage',
|
x_title='Forschungsunterfrage',
|
||||||
y_title='Anzahl der Vorkommen'
|
y_title='Anzahl der Vorkommen'
|
||||||
))
|
)
|
||||||
|
layout["font"] = {"size": 14, "color": colors['text']}
|
||||||
|
layout["title"] = {"font": {"size": 16}}
|
||||||
|
layout["margin"] = dict(b=160, t=60, l=40, r=40)
|
||||||
|
layout["xaxis"] = layout.get("xaxis", {})
|
||||||
|
layout["xaxis"]["tickangle"] = -45
|
||||||
|
layout["xaxis"]["automargin"] = True
|
||||||
|
layout["autosize"] = True
|
||||||
|
fig.update_layout(**layout)
|
||||||
fig.update_traces(marker=plot_styles['balken_primaryLine'])
|
fig.update_traces(marker=plot_styles['balken_primaryLine'])
|
||||||
fig.show(config={"responsive": True})
|
fig.show(config={"responsive": True})
|
||||||
export_figure(fig, "visualize_research_questions", export_fig_visualize_research_questions, bib_filename)
|
export_figure(fig, "visualize_research_questions", export_fig_visualize_research_questions, bib_filename)
|
||||||
@ -540,11 +568,19 @@ def visualize_categories(bib_database):
|
|||||||
print(tabulate(cat_data, headers="keys", tablefmt="grid"))
|
print(tabulate(cat_data, headers="keys", tablefmt="grid"))
|
||||||
|
|
||||||
fig = px.bar(cat_data_df, x='Category', y='Count', title=f'Textsortenzuordnung der analysierten Quellen (n={total_count}, Stand: {current_date})', labels={'Category': 'Kategorie', 'Count': 'Anzahl der Vorkommen'}, text_auto=True)
|
fig = px.bar(cat_data_df, x='Category', y='Count', title=f'Textsortenzuordnung der analysierten Quellen (n={total_count}, Stand: {current_date})', labels={'Category': 'Kategorie', 'Count': 'Anzahl der Vorkommen'}, text_auto=True)
|
||||||
fig.update_layout(**get_standard_layout(
|
layout = get_standard_layout(
|
||||||
title=fig.layout.title.text,
|
title=fig.layout.title.text,
|
||||||
x_title='Kategorie',
|
x_title='Kategorie',
|
||||||
y_title='Anzahl der Vorkommen'
|
y_title='Anzahl der Vorkommen'
|
||||||
))
|
)
|
||||||
|
layout["font"] = {"size": 14, "color": colors['text']}
|
||||||
|
layout["title"] = {"font": {"size": 16}}
|
||||||
|
layout["margin"] = dict(b=160, t=60, l=40, r=40)
|
||||||
|
layout["xaxis"] = layout.get("xaxis", {})
|
||||||
|
layout["xaxis"]["tickangle"] = -45
|
||||||
|
layout["xaxis"]["automargin"] = True
|
||||||
|
layout["autosize"] = True
|
||||||
|
fig.update_layout(**layout)
|
||||||
fig.update_traces(marker=plot_styles['balken_primaryLine'])
|
fig.update_traces(marker=plot_styles['balken_primaryLine'])
|
||||||
fig.show(config={"responsive": True})
|
fig.show(config={"responsive": True})
|
||||||
export_figure(fig, "visualize_categories", export_fig_visualize_categories, bib_filename)
|
export_figure(fig, "visualize_categories", export_fig_visualize_categories, bib_filename)
|
||||||
@ -588,6 +624,9 @@ def visualize_time_series(bib_database):
|
|||||||
dtick=2,
|
dtick=2,
|
||||||
tick0=min(publication_years)
|
tick0=min(publication_years)
|
||||||
)
|
)
|
||||||
|
layout["font"] = {"size": 14, "color": colors['text']}
|
||||||
|
layout["title"] = {"font": {"size": 16}}
|
||||||
|
layout["autosize"] = True
|
||||||
fig.update_layout(**layout)
|
fig.update_layout(**layout)
|
||||||
fig.update_traces(line=plot_styles['linie_secondaryLine'])
|
fig.update_traces(line=plot_styles['linie_secondaryLine'])
|
||||||
fig.show(config={"responsive": True})
|
fig.show(config={"responsive": True})
|
||||||
@ -610,11 +649,19 @@ def visualize_top_authors(bib_database):
|
|||||||
df = pd.DataFrame(top_authors, columns=['Author', 'Count'])
|
df = pd.DataFrame(top_authors, columns=['Author', 'Count'])
|
||||||
|
|
||||||
fig = px.bar(df, x='Author', y='Count', title=f'Meistgenannte Autor:innen in der Literaturanalyse (Top {top_n}, n={sum(author_counts.values())}, Stand: {current_date})', labels={'Author': 'Autor', 'Count': 'Anzahl der Werke'}, text_auto=True)
|
fig = px.bar(df, x='Author', y='Count', title=f'Meistgenannte Autor:innen in der Literaturanalyse (Top {top_n}, n={sum(author_counts.values())}, Stand: {current_date})', labels={'Author': 'Autor', 'Count': 'Anzahl der Werke'}, text_auto=True)
|
||||||
fig.update_layout(**get_standard_layout(
|
layout = get_standard_layout(
|
||||||
title=fig.layout.title.text,
|
title=fig.layout.title.text,
|
||||||
x_title='Autor',
|
x_title='Autor',
|
||||||
y_title='Anzahl der Werke'
|
y_title='Anzahl der Werke'
|
||||||
))
|
)
|
||||||
|
layout["font"] = {"size": 14, "color": colors['text']}
|
||||||
|
layout["title"] = {"font": {"size": 16}}
|
||||||
|
layout["margin"] = dict(b=160, t=60, l=40, r=40)
|
||||||
|
layout["xaxis"] = layout.get("xaxis", {})
|
||||||
|
layout["xaxis"]["tickangle"] = -45
|
||||||
|
layout["xaxis"]["automargin"] = True
|
||||||
|
layout["autosize"] = True
|
||||||
|
fig.update_layout(**layout)
|
||||||
fig.update_traces(marker=plot_styles['balken_primaryLine'])
|
fig.update_traces(marker=plot_styles['balken_primaryLine'])
|
||||||
fig.show(config={"responsive": True})
|
fig.show(config={"responsive": True})
|
||||||
export_figure(fig, "visualize_top_authors", export_fig_visualize_top_authors, bib_filename)
|
export_figure(fig, "visualize_top_authors", export_fig_visualize_top_authors, bib_filename)
|
||||||
@ -654,8 +701,13 @@ def visualize_top_publications(bib_database):
|
|||||||
x_title='Titel',
|
x_title='Titel',
|
||||||
y_title='Anzahl der Nennungen'
|
y_title='Anzahl der Nennungen'
|
||||||
)
|
)
|
||||||
|
layout["font"] = {"size": 14, "color": colors['text']}
|
||||||
|
layout["title"] = {"font": {"size": 16}}
|
||||||
|
layout["margin"] = dict(b=160, t=60, l=40, r=40)
|
||||||
layout["xaxis"] = layout.get("xaxis", {})
|
layout["xaxis"] = layout.get("xaxis", {})
|
||||||
layout["xaxis"]["tickangle"] = -45
|
layout["xaxis"]["tickangle"] = -45
|
||||||
|
layout["xaxis"]["automargin"] = True
|
||||||
|
layout["autosize"] = True
|
||||||
fig.update_layout(**layout)
|
fig.update_layout(**layout)
|
||||||
fig.update_traces(marker=plot_styles['balken_primaryLine'])
|
fig.update_traces(marker=plot_styles['balken_primaryLine'])
|
||||||
fig.show(config={"responsive": True})
|
fig.show(config={"responsive": True})
|
||||||
@ -788,9 +840,12 @@ def create_path_diagram(data):
|
|||||||
x_title='',
|
x_title='',
|
||||||
y_title=''
|
y_title=''
|
||||||
)
|
)
|
||||||
layout["font"] = dict(size=10, color=colors['white'])
|
# Erhöhe Lesbarkeit: größere Schrift, weißer Text
|
||||||
|
layout["font"] = dict(size=12, color=colors['text'])
|
||||||
|
layout["title"] = {"font": {"size": 16}}
|
||||||
|
layout["autosize"] = True
|
||||||
fig.update_layout(**layout)
|
fig.update_layout(**layout)
|
||||||
fig.show()
|
fig.show(config={"responsive": True})
|
||||||
export_figure(fig, "create_path_diagram", export_fig_create_path_diagram, bib_filename)
|
export_figure(fig, "create_path_diagram", export_fig_create_path_diagram, bib_filename)
|
||||||
|
|
||||||
|
|
||||||
@ -897,12 +952,15 @@ def create_sankey_diagram(bib_database):
|
|||||||
]
|
]
|
||||||
|
|
||||||
# Sankey-Diagramm erstellen
|
# Sankey-Diagramm erstellen
|
||||||
fig = go.Figure(go.Sankey(
|
node_config = {
|
||||||
node=dict(
|
|
||||||
**plot_styles["sankey_node"],
|
**plot_styles["sankey_node"],
|
||||||
label=node_labels,
|
"label": node_labels,
|
||||||
color=node_colors
|
"color": node_colors
|
||||||
),
|
}
|
||||||
|
# Remove any invalid 'font' key if present
|
||||||
|
node_config.pop("font", None)
|
||||||
|
fig = go.Figure(go.Sankey(
|
||||||
|
node=node_config,
|
||||||
link=dict(
|
link=dict(
|
||||||
**plot_styles["sankey_link"],
|
**plot_styles["sankey_link"],
|
||||||
source=sources,
|
source=sources,
|
||||||
@ -916,10 +974,12 @@ def create_sankey_diagram(bib_database):
|
|||||||
x_title='',
|
x_title='',
|
||||||
y_title=''
|
y_title=''
|
||||||
)
|
)
|
||||||
layout["font"] = layout.get("font", {})
|
# Erhöhe Lesbarkeit: größere Schrift, weißer Text
|
||||||
layout["font"]["size"] = 12
|
layout["font"] = dict(size=12, color=colors['text'])
|
||||||
|
layout["title"] = {"font": {"size": 16}}
|
||||||
|
layout["autosize"] = True
|
||||||
fig.update_layout(**layout)
|
fig.update_layout(**layout)
|
||||||
fig.show()
|
fig.show(config={"responsive": True})
|
||||||
export_figure(fig, "create_sankey_diagram", export_fig_create_sankey_diagram, bib_filename)
|
export_figure(fig, "create_sankey_diagram", export_fig_create_sankey_diagram, bib_filename)
|
||||||
|
|
||||||
##########
|
##########
|
||||||
@ -1036,12 +1096,18 @@ def visualize_sources_status(bib_database):
|
|||||||
y_title='Anzahl der Quellen'
|
y_title='Anzahl der Quellen'
|
||||||
)
|
)
|
||||||
layout["barmode"] = "stack"
|
layout["barmode"] = "stack"
|
||||||
|
layout["font"] = {"size": 14, "color": colors['text']}
|
||||||
|
layout["title"] = {"font": {"size": 16}}
|
||||||
|
layout["margin"] = dict(b=160, t=60, l=40, r=40)
|
||||||
layout["xaxis"] = dict(
|
layout["xaxis"] = dict(
|
||||||
categoryorder='array',
|
categoryorder='array',
|
||||||
categoryarray=search_folder_tags
|
categoryarray=search_folder_tags,
|
||||||
|
tickangle=-45,
|
||||||
|
automargin=True
|
||||||
)
|
)
|
||||||
|
layout["autosize"] = True
|
||||||
fig.update_layout(**layout)
|
fig.update_layout(**layout)
|
||||||
fig.show()
|
fig.show(config={"responsive": True})
|
||||||
export_figure(fig, "visualize_sources_status", export_fig_visualize_sources_status, bib_filename)
|
export_figure(fig, "visualize_sources_status", export_fig_visualize_sources_status, bib_filename)
|
||||||
|
|
||||||
#############
|
#############
|
||||||
@ -1071,7 +1137,7 @@ def create_wordcloud_from_titles(bib_database, stop_words):
|
|||||||
plt.figure(figsize=(10, 5))
|
plt.figure(figsize=(10, 5))
|
||||||
plt.imshow(wordcloud, interpolation='bilinear')
|
plt.imshow(wordcloud, interpolation='bilinear')
|
||||||
plt.axis('off')
|
plt.axis('off')
|
||||||
plt.title(f'Häufigkeitsanalyse von Titelwörtern (Stand: {current_date}) | Quelle: {bib_filename.replace(".bib", "")}', color=colors['white'])
|
plt.title(f'Häufigkeitsanalyse von Titelwörtern (Stand: {current_date}) | Quelle: {bib_filename.replace(".bib", "")}', color=colors['text'])
|
||||||
plt.show()
|
plt.show()
|
||||||
|
|
||||||
if export_fig_create_wordcloud_from_titles and bib_filename:
|
if export_fig_create_wordcloud_from_titles and bib_filename:
|
||||||
|
|||||||
Reference in New Issue
Block a user