Files changed (1) hide show
  1. visual1.py +9 -41
visual1.py CHANGED
@@ -17,9 +17,9 @@ def _():
17
  @app.cell
18
  def _(pd):
19
  # ===== IMPORT DATASETS =====
20
- coffeeyield = pd.read_excel("Coffee_yield.xlsx")
21
- coffeestructureindex_management = pd.read_excel("Environmental_and_management_variables.xlsx")
22
- plant_species_richness = pd.read_excel("Plant_species_richness.xlsx")
23
  return coffeestructureindex_management, coffeeyield, plant_species_richness
24
 
25
 
@@ -28,7 +28,7 @@ def _(pd):
28
  # ===== PREPARE WOODY DATA =====
29
 
30
  #Load the excelfile
31
- woody_species_abundance = pd.read_excel("Woody_species_abundance.xlsx")
32
  woody_species_abundance
33
 
34
  #Creating dataframe of total abundance of woody species, per Site ID
@@ -52,7 +52,7 @@ def _(pd):
52
  # ===== PREPARE BRYOPHYTE DATA =====
53
 
54
  #Load the txtfile
55
- bryophyte_species_abundance = pd.read_csv("Bryophyte_frequency.txt", sep="\t")
56
 
57
  #Creating dataframe of total abundance of bryo species, per Site ID
58
  bryo_totals = bryophyte_species_abundance.iloc[:, 1:].sum().reset_index()
@@ -111,7 +111,7 @@ def _(pd):
111
  # ===== PREPARE HERB DATA =====
112
 
113
  #Load the txtfile
114
- herb_species_abundance = pd.read_csv("Herbaceous_vegetation_Abundance.txt", sep="\t")
115
 
116
  #Set Site ID as index and then sum species columns for total abundance
117
  herb_totals = herb_species_abundance.set_index(herb_species_abundance.columns[0]).iloc[:, :].sum(axis=1).reset_index()
@@ -151,33 +151,8 @@ def _(
151
 
152
  @app.cell
153
  def _(filtered_flowers, filtered_for_plot, pd):
154
- # # ===== PREPARE CLUSTER DATA FOR HISTOGRAMS =====
155
- # # Load cluster distribution data
156
- # Coffee_structure_index_variables = pd.read_excel("Coffee_structure_index_variables.xlsx")
157
- # cluster_data = Coffee_structure_index_variables.copy()
158
- # cluster_data
159
-
160
- # # Group by Site ID and count clusters
161
- # cluster_counts = cluster_data.groupby(['Site ID', 'Fitted cluster']).size().unstack(fill_value=0)
162
-
163
- # # Ensure all clusters exist (1, 2, 3)
164
- # for cluster in [1, 2, 3]:
165
- # if cluster not in cluster_counts.columns:
166
- # cluster_counts[cluster] = 0
167
-
168
- # # Get only sites in filtered_flowers
169
- # cluster_counts = cluster_counts.loc[cluster_counts.index.isin(filtered_flowers['Site ID'])]
170
-
171
- # # Sort by ordinal_pos to match graph order
172
- # cluster_counts = cluster_counts.join(
173
- # filtered_for_plot[['Site ID', 'ordinal_pos']].set_index('Site ID'),
174
- # how='left'
175
- # )
176
- # cluster_counts = cluster_counts.sort_values('ordinal_pos')
177
- # cluster_counts
178
-
179
  # ===== PREPARE CLUSTER DATA FOR HISTOGRAMS =====
180
- cluster_data = pd.read_excel("Coffee_structure_index_variables.xlsx")
181
 
182
  # Simple: group by Site ID and cluster, count rows
183
  cluster_counts = cluster_data.groupby(['Site ID', 'Fitted cluster']).size().unstack(fill_value=0)
@@ -197,7 +172,7 @@ def _(filtered_flowers, filtered_for_plot, pd):
197
  # FIX: Rename integer columns to strings
198
  cluster_counts.columns = cluster_counts.columns.astype(str)
199
 
200
- cluster_counts
201
  return cluster_counts, cluster_data, col, site_order
202
 
203
 
@@ -376,13 +351,6 @@ def _(mo):
376
  return (filter_selector,)
377
 
378
 
379
- @app.cell
380
- def _(frame_padding, legend_y, legend_y_richness):
381
- print(legend_y_richness + 100 - (legend_y - frame_padding))
382
- print(legend_y - frame_padding)
383
- return
384
-
385
-
386
  @app.cell
387
  def _(
388
  Circle,
@@ -574,7 +542,7 @@ def _(
574
 
575
  # Colors for clusters
576
  cluster_colors = {
577
- '1': "#2d46dc", # Purple
578
  '2': "#91d76e", # Green
579
  '3': "#be2d32" # Red
580
  }
 
17
  @app.cell
18
  def _(pd):
19
  # ===== IMPORT DATASETS =====
20
+ coffeeyield = pd.read_excel("data/Coffee_yield.xlsx")
21
+ coffeestructureindex_management = pd.read_excel("data/Environmental_and_management_variables.xlsx")
22
+ plant_species_richness = pd.read_excel("data/Plant_species_richness.xlsx")
23
  return coffeestructureindex_management, coffeeyield, plant_species_richness
24
 
25
 
 
28
  # ===== PREPARE WOODY DATA =====
29
 
30
  #Load the excelfile
31
+ woody_species_abundance = pd.read_excel("data/Woody_species_abundance.xlsx")
32
  woody_species_abundance
33
 
34
  #Creating dataframe of total abundance of woody species, per Site ID
 
52
  # ===== PREPARE BRYOPHYTE DATA =====
53
 
54
  #Load the txtfile
55
+ bryophyte_species_abundance = pd.read_csv("data/Bryophyte_frequency.txt", sep="\t")
56
 
57
  #Creating dataframe of total abundance of bryo species, per Site ID
58
  bryo_totals = bryophyte_species_abundance.iloc[:, 1:].sum().reset_index()
 
111
  # ===== PREPARE HERB DATA =====
112
 
113
  #Load the txtfile
114
+ herb_species_abundance = pd.read_csv("data/Herbaceous_vegetation_Abundance.txt", sep="\t")
115
 
116
  #Set Site ID as index and then sum species columns for total abundance
117
  herb_totals = herb_species_abundance.set_index(herb_species_abundance.columns[0]).iloc[:, :].sum(axis=1).reset_index()
 
151
 
152
  @app.cell
153
  def _(filtered_flowers, filtered_for_plot, pd):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
154
  # ===== PREPARE CLUSTER DATA FOR HISTOGRAMS =====
155
+ cluster_data = pd.read_excel("data/Coffee_structure_index_variables.xlsx")
156
 
157
  # Simple: group by Site ID and cluster, count rows
158
  cluster_counts = cluster_data.groupby(['Site ID', 'Fitted cluster']).size().unstack(fill_value=0)
 
172
  # FIX: Rename integer columns to strings
173
  cluster_counts.columns = cluster_counts.columns.astype(str)
174
 
175
+ #cluster_counts
176
  return cluster_counts, cluster_data, col, site_order
177
 
178
 
 
351
  return (filter_selector,)
352
 
353
 
 
 
 
 
 
 
 
354
  @app.cell
355
  def _(
356
  Circle,
 
542
 
543
  # Colors for clusters
544
  cluster_colors = {
545
+ '1': "#2d46dc",
546
  '2': "#91d76e", # Green
547
  '3': "#be2d32" # Red
548
  }