lynn-twinkl commited on
Commit ·
cbff612
1
Parent(s): 0125b5b
bol text for hover keys
Browse files- src/px_charts.py +17 -8
src/px_charts.py
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
|
|
| 1 |
import pandas as pd
|
| 2 |
import plotly.express as px
|
| 3 |
|
| 4 |
|
| 5 |
-
title_font_size=
|
| 6 |
title_font_color='#808393'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
def plot_histogram(df: pd.DataFrame, col_to_plot: str, bins: int, height: int = 500, title:str = None):
|
| 9 |
|
|
@@ -19,7 +25,10 @@ def plot_histogram(df: pd.DataFrame, col_to_plot: str, bins: int, height: int =
|
|
| 19 |
bargap=0.1,
|
| 20 |
height=height,
|
| 21 |
title_font_size=title_font_size,
|
| 22 |
-
title_font_color=title_font_color
|
|
|
|
|
|
|
|
|
|
| 23 |
)
|
| 24 |
|
| 25 |
return plt
|
|
@@ -52,22 +61,22 @@ def plot_topic_countplot(topics_df: pd.DataFrame, topic_id_col: str, topic_name_
|
|
| 52 |
marker_color='#EF64B3',
|
| 53 |
textposition='outside',
|
| 54 |
hovertemplate=(
|
| 55 |
-
'Topic Name: %{customdata[1]}<br>'
|
| 56 |
-
'Frequency: %{y}<br>'
|
| 57 |
-
'Top 5 words: %{customdata[0]}<extra></extra>'
|
| 58 |
)
|
| 59 |
)
|
| 60 |
|
| 61 |
plt.update_layout(
|
| 62 |
-
uniformtext_minsize=10,
|
| 63 |
height=height,
|
| 64 |
hoverlabel=dict(
|
| 65 |
font_size=13,
|
| 66 |
align="left"
|
| 67 |
),
|
| 68 |
title_font_size=title_font_size,
|
| 69 |
-
title_font_color=title_font_color
|
| 70 |
-
|
|
|
|
| 71 |
)
|
| 72 |
|
| 73 |
|
|
|
|
| 1 |
+
# ========= CONFIGURATION ==========
|
| 2 |
import pandas as pd
|
| 3 |
import plotly.express as px
|
| 4 |
|
| 5 |
|
| 6 |
+
title_font_size=20
|
| 7 |
title_font_color='#808393'
|
| 8 |
+
xaxis_title_font_size=16
|
| 9 |
+
yaxis_title_font_size=16
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
# ======== FUNCTIONS ========
|
| 13 |
|
| 14 |
def plot_histogram(df: pd.DataFrame, col_to_plot: str, bins: int, height: int = 500, title:str = None):
|
| 15 |
|
|
|
|
| 25 |
bargap=0.1,
|
| 26 |
height=height,
|
| 27 |
title_font_size=title_font_size,
|
| 28 |
+
title_font_color=title_font_color,
|
| 29 |
+
xaxis_title_font_size=xaxis_title_font_size,
|
| 30 |
+
yaxis_title_font_size=yaxis_title_font_size,
|
| 31 |
+
|
| 32 |
)
|
| 33 |
|
| 34 |
return plt
|
|
|
|
| 61 |
marker_color='#EF64B3',
|
| 62 |
textposition='outside',
|
| 63 |
hovertemplate=(
|
| 64 |
+
'<b>Topic Name</b>: %{customdata[1]}<br>'
|
| 65 |
+
'<b>Frequency:</b> %{y}<br>'
|
| 66 |
+
'<b>Top 5 words:</b> %{customdata[0]}<extra></extra>'
|
| 67 |
)
|
| 68 |
)
|
| 69 |
|
| 70 |
plt.update_layout(
|
|
|
|
| 71 |
height=height,
|
| 72 |
hoverlabel=dict(
|
| 73 |
font_size=13,
|
| 74 |
align="left"
|
| 75 |
),
|
| 76 |
title_font_size=title_font_size,
|
| 77 |
+
title_font_color=title_font_color,
|
| 78 |
+
xaxis_title_font_size=xaxis_title_font_size,
|
| 79 |
+
yaxis_title_font_size=yaxis_title_font_size,
|
| 80 |
)
|
| 81 |
|
| 82 |
|