zavavan commited on
Commit
9d5ea5c
·
verified ·
1 Parent(s): eefadc5

Upload dashboard.py

Browse files
Files changed (1) hide show
  1. dashboard.py +16 -4
dashboard.py CHANGED
@@ -148,16 +148,28 @@ grouping_filtered = pd.read_csv(os.path.join(data_folder, 'dna_relations.tsv'),
148
 
149
 
150
  ################################# CREATE CHARTS ############################
 
 
 
 
 
 
 
151
  def create_publication_curve_chart():
 
 
 
 
 
152
  total_publications_time_indexed.id = np.log1p(total_publications_time_indexed.id)
153
- country_publications_time_indexed_normalized = country_publications_time_indexed.applymap(lambda x: np.log1p(x) if np.issubdtype(type(x), np.number) else x)
154
- curve_total = hv.Curve((total_publications_time_indexed.index, total_publications_time_indexed.id), 'Time', 'Publication Counts (log)', label='Total')
155
  #Overlay the line plots
156
  overlay = curve_total
157
  curve_countries = []
158
  for country in country_name_map.keys():
159
- overlay = overlay * hv.Curve((country_publications_time_indexed_normalized.index, country_publications_time_indexed_normalized[country]), label=country_name_map[country])
160
- overlay.opts(show_legend=True,legend_position='right', width=1400, height=600 )
161
  return overlay
162
 
163
 
 
148
 
149
 
150
  ################################# CREATE CHARTS ############################
151
+ ################################# CREATE CHARTS ############################
152
+
153
+ # Hook function to customize x-axis for Bokeh
154
+ def customize_x_axis_bokeh(plot, element):
155
+ bokeh_plot = plot.state
156
+ bokeh_plot.xaxis.major_label_orientation = 45 # Rotate x-axis labels
157
+
158
  def create_publication_curve_chart():
159
+ country_name_df = pd.read_csv(os.path.join(data_folder, 'country_name_map.tsv'), header=0, sep='\t', lineterminator='\n', low_memory=False)
160
+ country_name_map = dict(zip(country_name_df.Country_Code, country_name_df.Country_Name))
161
+ country_name_map
162
+ total_publications_time_indexed = pd.read_csv(os.path.join(data_folder, 'total_publications_time_indexed.tsv'), header=0, sep='\t', lineterminator='\n', low_memory=False)
163
+ country_publications_time_indexed = pd.read_csv(os.path.join(data_folder, 'country_publications_time_indexed.tsv'), header=0, sep='\t', lineterminator='\n', low_memory=False)
164
  total_publications_time_indexed.id = np.log1p(total_publications_time_indexed.id)
165
+ country_publications_time_indexed = country_publications_time_indexed.applymap(lambda x: np.log1p(x) if np.issubdtype(type(x), np.number) else x)
166
+ curve_total = hv.Curve((total_publications_time_indexed.month_bin, total_publications_time_indexed.id), 'Time', 'Publication Counts (log)',label='Total')
167
  #Overlay the line plots
168
  overlay = curve_total
169
  curve_countries = []
170
  for country in country_name_map.keys():
171
+ overlay = overlay * hv.Curve((total_publications_time_indexed.month_bin, country_publications_time_indexed[country]), label=country_name_map[country])
172
+ overlay.opts(show_legend=True,legend_position='right', width=1200, height=600, hooks=[customize_x_axis_bokeh])
173
  return overlay
174
 
175