Hack90 commited on
Commit
3b44efa
·
verified ·
1 Parent(s): 88197ec

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -8
app.py CHANGED
@@ -173,15 +173,26 @@ with ui.navset_card_tab(id="tab"):
173
  import seaborn as sns
174
  plot_type = input.plot_type_distro_sub()
175
  if plot_type == "2D sub-specie - nominal":
176
- df = pd.read_parquet('virus_ds.parquet')
177
  df = process_data_sub_specie(df, input.virus_selector_2(), input.variance())
178
- df = df.explode('two_d').copy()
179
- df['x'] = np.array((df['two_d'].tolist()))[:,0]
180
- df['y'] = np.array((df['two_d'].tolist()))[:,1]
181
- ax = sns.scatterplot(data=df, x='x',y='y', hue='group')
182
- ax.set_title("Sub-specie")
183
- # ax.set_xlabel("")
184
- # ax.set_ylabel("Density")
 
 
 
 
 
 
 
 
 
 
 
185
  return ax
186
 
187
 
 
173
  import seaborn as sns
174
  plot_type = input.plot_type_distro_sub()
175
  if plot_type == "2D sub-specie - nominal":
176
+ df = pd.read_parquet('new_viral_dataset.parquet')
177
  df = process_data_sub_specie(df, input.virus_selector_2(), input.variance())
178
+ fig, ax = plt.subplots()
179
+ # Get unique groups and assign colors
180
+ groups = df['group'].unique()
181
+ colors = plt.cm.rainbow(np.linspace(0, 1, len(groups)))
182
+ color_dict = dict(zip(groups, colors))
183
+
184
+ # Iterate through rows and plot
185
+ for _, row in df.iterrows():
186
+ x, y = zip(*row['two_d'])
187
+ ax.plot(x, y, c=color_dict[row['group']])
188
+
189
+ # Remove duplicate labels
190
+ handles, labels = ax.get_legend_handles_labels()
191
+ by_label = dict(zip(labels, handles))
192
+ #ax.legend(by_label.values(), by_label.keys())
193
+
194
+ ax.set_title("Sub-specie"))
195
+
196
  return ax
197
 
198