lynn-twinkl commited on
Commit
d66308d
·
1 Parent(s): c35a466

dded chart titles and title colors

Browse files
Files changed (1) hide show
  1. src/px_charts.py +15 -6
src/px_charts.py CHANGED
@@ -1,19 +1,25 @@
1
  import pandas as pd
2
  import plotly.express as px
3
 
4
- def plot_histogram(df: pd.DataFrame, col_to_plot: str, bins: int, height: int = 500):
 
 
 
 
5
 
6
  plt = px.histogram(
7
  df,
8
  x=col_to_plot,
9
  nbins=bins,
10
- title=None,
11
  color_discrete_sequence=['#646DEF']
12
  )
13
 
14
  plt.update_layout(
15
  bargap=0.1,
16
- height=height
 
 
17
  )
18
 
19
  return plt
@@ -22,7 +28,7 @@ def plot_histogram(df: pd.DataFrame, col_to_plot: str, bins: int, height: int =
22
  # =========== TOPIC DISTRIBUTION CHART ===========
23
 
24
 
25
- def plot_topic_countplot(topics_df: pd.DataFrame, topic_id_col: str, topic_name_col: str, representation_col: str, height: int = 500):
26
  """
27
  This functions plots a count chart for Bertopic topics,
28
  extracting the 5 words of each topic's representation
@@ -37,7 +43,7 @@ def plot_topic_countplot(topics_df: pd.DataFrame, topic_id_col: str, topic_name_
37
  x=topic_id_col,
38
  y='Count',
39
  custom_data=["top_5_words", topic_name_col],
40
- title=None,
41
  )
42
 
43
  plt.update_xaxes(type='category')
@@ -58,7 +64,10 @@ def plot_topic_countplot(topics_df: pd.DataFrame, topic_id_col: str, topic_name_
58
  hoverlabel=dict(
59
  font_size=13,
60
  align="left"
61
- )
 
 
 
62
  )
63
 
64
 
 
1
  import pandas as pd
2
  import plotly.express as px
3
 
4
+
5
+ title_font_size=18
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
 
10
  plt = px.histogram(
11
  df,
12
  x=col_to_plot,
13
  nbins=bins,
14
+ title=title,
15
  color_discrete_sequence=['#646DEF']
16
  )
17
 
18
  plt.update_layout(
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
 
28
  # =========== TOPIC DISTRIBUTION CHART ===========
29
 
30
 
31
+ def plot_topic_countplot(topics_df: pd.DataFrame, topic_id_col: str, topic_name_col: str, representation_col: str, height: int = 500, title:str = None):
32
  """
33
  This functions plots a count chart for Bertopic topics,
34
  extracting the 5 words of each topic's representation
 
43
  x=topic_id_col,
44
  y='Count',
45
  custom_data=["top_5_words", topic_name_col],
46
+ title=title,
47
  )
48
 
49
  plt.update_xaxes(type='category')
 
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