Files changed (1) hide show
  1. visual1.py +1166 -0
visual1.py ADDED
@@ -0,0 +1,1166 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import marimo
2
+
3
+ __generated_with = "0.11.26"
4
+ app = marimo.App(width="medium")
5
+
6
+
7
+ @app.cell
8
+ def _():
9
+ import marimo as mo
10
+ import pandas as pd
11
+ import math
12
+ from svg import SVG, Circle, Text, G, Line, Ellipse, Rect, Title
13
+ import numpy as np
14
+ return Circle, Ellipse, G, Line, Rect, SVG, Text, Title, math, mo, np, pd
15
+
16
+
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
+
26
+ @app.cell
27
+ 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
35
+ woody_totals = woody_species_abundance.iloc[:, 1:].sum().reset_index()
36
+
37
+ #Rename the columns to meaningful names
38
+ woody_totals.columns = ["Site ID", "Woody_total"]
39
+
40
+ #Normalise the abundance values to 0-100 scale for comparability
41
+ #Divide each value by max (0-1 scale) and multiply by 100 (0-100 scale)
42
+ woody_totals["Woody_abundance"] = (woody_totals["Woody_total"] / woody_totals["Woody_total"].max()) * 100
43
+
44
+ #Keep only the Site ID and normalised abundance columns
45
+ w_abundance = woody_totals[["Site ID", "Woody_abundance"]]
46
+ #w_abundance
47
+ return w_abundance, woody_species_abundance, woody_totals
48
+
49
+
50
+ @app.cell
51
+ 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()
59
+
60
+ #Rename the columns to meaningful names
61
+ bryo_totals.columns = ["Site ID", "Bryo_total"]
62
+
63
+ #Normalise the abundance values to 0-100 scale for comparability
64
+ #Divide each value by max (0-1 scale) and multiply by 100 (0-100 scale)
65
+ bryo_totals["Bryo_abundance"] = (bryo_totals["Bryo_total"] / bryo_totals["Bryo_total"].max()) * 100
66
+
67
+ #Keep only the Site ID and normalised abundance columns
68
+ b_abundance = bryo_totals[["Site ID", "Bryo_abundance"]]
69
+ #b_abundance
70
+ return b_abundance, bryo_totals, bryophyte_species_abundance
71
+
72
+
73
+ @app.cell(hide_code=True)
74
+ def _():
75
+ # # ===== VERIFY BRYOPHYTE DATA =====
76
+
77
+ # # See the raw totals BEFORE normalization
78
+ # print("Raw bryophyte totals (before normalization):")
79
+ # print(bryo_totals[["Site ID", "Bryo_total"]])
80
+
81
+ # # See which site has the max
82
+ # print(f"\nMax bryo total: {bryo_totals['Bryo_total'].max()}")
83
+
84
+ # # Check a specific site (e.g., Ge1)
85
+ # ge1_row = bryo_totals[bryo_totals["Site ID"] == "Ge1"]
86
+ # if not ge1_row.empty:
87
+ # ge1_raw = ge1_row["Bryo_total"].values[0]
88
+ # print(f"Ge1 raw total: {ge1_raw}")
89
+
90
+ # # Verify the normalization calculation manually
91
+ # ge1_normalized_manual = (ge1_raw / bryo_totals["Bryo_total"].max()) * 100
92
+ # ge1_normalized_actual = ge1_row["Bryo_abundance"].values[0]
93
+
94
+ # print(f"Ge1 normalized (manual calc): {ge1_normalized_manual:.2f}")
95
+ # print(f"Ge1 normalized (from data): {ge1_normalized_actual:.2f}")
96
+ # print(f"Match: {abs(ge1_normalized_manual - ge1_normalized_actual) < 0.01}")
97
+ # else:
98
+ # print("Ge1 not found in data")
99
+
100
+ # # Show distribution
101
+ # print(f"\nBryo abundance range: {bryo_totals['Bryo_abundance'].min():.2f} to {bryo_totals['Bryo_abundance'].max():.2f}")
102
+
103
+ # # Display final result
104
+ # print("\nFinal bryophyte abundance (0-100 scale):")
105
+ # print(b_abundance.head(10))
106
+ return
107
+
108
+
109
+ @app.cell
110
+ 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()
118
+
119
+ #Rename the columns to meaningful names
120
+ herb_totals.columns = ["Site ID", "Herb_total"]
121
+
122
+ #Normalise the abundance values to 0-100 scale for comparability
123
+ #Divide each value by max (0-1 scale) and multiply by 100 (0-100 scale)
124
+ herb_totals["Herb_abundance"] = (herb_totals["Herb_total"] / herb_totals["Herb_total"].max()) * 100
125
+ herb_totals
126
+
127
+ #Keep only the Site ID and normalised abundance columns
128
+ h_abundance = herb_totals[["Site ID", "Herb_abundance"]]
129
+ #h_abundance
130
+ return h_abundance, herb_species_abundance, herb_totals
131
+
132
+
133
+ @app.cell
134
+ def _(
135
+ b_abundance,
136
+ coffeestructureindex_management,
137
+ coffeeyield,
138
+ h_abundance,
139
+ plant_species_richness,
140
+ w_abundance,
141
+ ):
142
+ merged = coffeeyield \
143
+ .merge(coffeestructureindex_management, on="Site ID") \
144
+ .merge(plant_species_richness, on="Site ID") \
145
+ .merge(w_abundance, on="Site ID")\
146
+ .merge(b_abundance, on="Site ID")\
147
+ .merge(h_abundance, on="Site ID")
148
+ merged
149
+ return (merged,)
150
+
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)
184
+
185
+ # Make sure we have columns 1, 2, 3 (add if missing)
186
+ for col in [1, 2, 3]:
187
+ if col not in cluster_counts.columns:
188
+ cluster_counts[col] = 0
189
+
190
+ # Keep only sites we're showing
191
+ cluster_counts = cluster_counts[cluster_counts.index.isin(filtered_flowers['Site ID'])]
192
+
193
+ # Sort to match graph order
194
+ site_order = filtered_for_plot[filtered_for_plot['Site ID'].isin(cluster_counts.index)].set_index('Site ID')
195
+ cluster_counts = cluster_counts.loc[site_order.index]
196
+
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
+
204
+ @app.cell
205
+ def _(filter_selector, merged, pd):
206
+ # ===== PREPARE DATA FOR VISUALISATION. =====
207
+
208
+ # ===== CREATING TWO VARIABLES FOR SELECTOR: one for plotting whole graph, one for filtering flowers only =====
209
+
210
+ #Determine which sites to display (all variables for axis/background)
211
+ filtered_for_plot = merged.copy()
212
+ filtered_for_plot = filtered_for_plot.sort_values("Coffee structure index").reset_index(drop=True)
213
+ filtered_for_plot["ordinal_pos"] = range(1, len(filtered_for_plot) + 1)
214
+
215
+ # Define min/max yield for ALL sites (needed for axes)
216
+ filtered_for_plot["min_yield"] = filtered_for_plot[["CC_Yield_2017", "CC_Yield_2018", "CC_Yield_2019"]].min(axis=1, skipna=True)
217
+ filtered_for_plot["max_yield"] = filtered_for_plot[["CC_Yield_2017", "CC_Yield_2018", "CC_Yield_2019"]].max(axis=1, skipna=True)
218
+
219
+ #Determine which flowers are shown (changes based on filter)
220
+ if filter_selector.value == "All sites":
221
+ filtered_flowers = filtered_for_plot.copy()
222
+ show_labels = False
223
+ else: # "Top 10 + Bottom 10 yield"
224
+ t10 = merged.nlargest(10, "Mean_CC_Yield")
225
+ b10 = merged.nsmallest(10, "Mean_CC_Yield")
226
+ filtered_flowers = pd.concat([t10, b10]).sort_values("Coffee structure index").reset_index(drop=True)
227
+ show_labels = True
228
+
229
+ # Add ordinal_pos, min_yield, max_yield from filtered_for_plot + add if to avoid duplicates (every time code runs)
230
+ if "ordinal_pos" not in filtered_flowers.columns:
231
+ filtered_flowers = filtered_flowers.merge(
232
+ filtered_for_plot[["Site ID", "ordinal_pos", "min_yield", "max_yield"]],
233
+ on="Site ID",
234
+ how="left"
235
+ )
236
+
237
+ # ===== PREPERATION OF RICHNESS VARIABLE: CALCULATE MIN/MAX RICHNESS FOR NORMALIZATION =====
238
+ herb_richness_min = filtered_flowers["Veg_Spps"].min()
239
+ herb_richness_max = filtered_flowers["Veg_Spps"].max()
240
+ bryo_richness_min = filtered_flowers["Bryo_Spps"].min()
241
+ bryo_richness_max = filtered_flowers["Bryo_Spps"].max()
242
+ woody_richness_min = filtered_flowers["Woody_Spps"].min()
243
+ woody_richness_max = filtered_flowers["Woody_Spps"].max()
244
+
245
+ # Function to normalize richness and convert to opacity in petals
246
+ def get_opacity_from_richness(value, min_val, max_val):
247
+ if max_val == min_val: # Handle case where all values are the same
248
+ normalized = 0.5
249
+ else:
250
+ normalized = (value - min_val) / (max_val - min_val)
251
+ return 0.2 + (normalized * 0.8) # Maps to 0.2-1.0 opacity range
252
+
253
+
254
+ # ===== EXTRACT VARIABLES for plotting ======
255
+ structureindex = filtered_for_plot["Coffee structure index"]
256
+ mean_coffee_yield = filtered_for_plot["Mean_CC_Yield"]
257
+ site_id = filtered_for_plot["Site ID"]
258
+ herb_abundance = filtered_for_plot["Herb_abundance"]
259
+ bryo_abundance = filtered_for_plot["Bryo_abundance"]
260
+ woody_abundance = filtered_for_plot["Woody_abundance"]
261
+ ordinal_pos = filtered_for_plot["ordinal_pos"]
262
+
263
+ #Extract variables for flowers (filtered)
264
+ flower_sites = filtered_flowers["Site ID"].tolist()
265
+
266
+ print(f"All sites to display: {len(filtered_for_plot)}")
267
+ print(f"Flowers to show: {len(filtered_flowers)}")
268
+ return (
269
+ b10,
270
+ bryo_abundance,
271
+ bryo_richness_max,
272
+ bryo_richness_min,
273
+ filtered_flowers,
274
+ filtered_for_plot,
275
+ flower_sites,
276
+ get_opacity_from_richness,
277
+ herb_abundance,
278
+ herb_richness_max,
279
+ herb_richness_min,
280
+ mean_coffee_yield,
281
+ ordinal_pos,
282
+ show_labels,
283
+ site_id,
284
+ structureindex,
285
+ t10,
286
+ woody_abundance,
287
+ woody_richness_max,
288
+ woody_richness_min,
289
+ )
290
+
291
+
292
+ @app.cell
293
+ def _():
294
+ # filtered_for_plot
295
+ # filtered_flowers
296
+ return
297
+
298
+
299
+ @app.cell
300
+ def _():
301
+ #svg frame
302
+ svg_width=2350
303
+ svg_height=1300
304
+ return svg_height, svg_width
305
+
306
+
307
+ @app.cell
308
+ def _(mo):
309
+ mo.md(
310
+ """
311
+ <!-- CSS for layout of svg-->
312
+ <style>
313
+ svg.abc {
314
+ border: 1px solid;
315
+ background: #fafafa;
316
+ border-radius: 4px;
317
+ box-shadow: 0 1px 3px rgba(0,0,0,0.1);
318
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
319
+ }
320
+ .axis-label {
321
+ font-size: 11px;
322
+ fill: #333;
323
+ }
324
+ .axis-title {
325
+ font-size: 13px;
326
+ fill: #222;
327
+ font-weight: 500;
328
+ }
329
+ .main-title {
330
+ font-size: 20px;
331
+ fill: black;
332
+ font-weight: 600;
333
+ }
334
+
335
+ .subtitle {
336
+ font-size: 11px;
337
+ fill: #6b7280;
338
+ font-weight: 400;
339
+ }
340
+
341
+ circle.nq1 {
342
+ fill: #2563eb;
343
+ stroke: #1e40af;
344
+ stroke-width: 0.5px;
345
+ opacity: 0.6;
346
+ }
347
+
348
+ ellipse {
349
+ stroke: none;
350
+ }
351
+
352
+ line {
353
+ stroke-linecap: round;
354
+ stroke-linejoin: round;
355
+ }
356
+ </style>
357
+ """
358
+ )
359
+ return
360
+
361
+
362
+ @app.cell
363
+ def _(mo):
364
+ flower_size = mo.ui.slider(start=1, stop=2, step=0.25, value=1, label="Flower size")
365
+ flower_size
366
+ return (flower_size,)
367
+
368
+
369
+ @app.cell
370
+ def _(mo):
371
+ filter_selector = mo.ui.dropdown(
372
+ options=["All sites", "Top 10 yield & Bottom 10 yield"],
373
+ label="Show sites"
374
+ )
375
+ filter_selector
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,
389
+ Ellipse,
390
+ Line,
391
+ Rect,
392
+ SVG,
393
+ Text,
394
+ bryo_richness_max,
395
+ bryo_richness_min,
396
+ cluster_counts,
397
+ filter_selector,
398
+ filtered_flowers,
399
+ filtered_for_plot,
400
+ flower_size,
401
+ get_opacity_from_richness,
402
+ herb_richness_max,
403
+ herb_richness_min,
404
+ math,
405
+ mo,
406
+ ordinal_pos,
407
+ structureindex,
408
+ svg_height,
409
+ svg_width,
410
+ woody_richness_max,
411
+ woody_richness_min,
412
+ ):
413
+ #creating variable 'elements'
414
+ _elements = []
415
+
416
+ #Scaling of x-axis and y-axis
417
+ margin = 90
418
+ top_margin = 20 #add extra space at top for title
419
+ usable_width = svg_width - 6 * margin + 30
420
+ usable_height = svg_height - 2 * margin -top_margin
421
+
422
+ x_min = 1
423
+ x_max = 3
424
+
425
+ y_min = 0
426
+ y_max = 5500
427
+
428
+ num_sites = len(filtered_for_plot)
429
+
430
+
431
+ #===== LOOP FOR DRAWING ELEMENTS =====
432
+ #adding elements to svg - loop for circles, flower petals and dashed lines of min-max yield
433
+ #but instead of looping through all sites, we will loop through filtered_flowers (for selection 60 vs 20 site ids)
434
+ for structure_, yield_, site_, herb_, bryo_, woody_, herb_richness, bryo_richness, woody_richness, min_y, max_y, ord_pos in zip(
435
+ filtered_flowers["Coffee structure index"],
436
+ filtered_flowers["Mean_CC_Yield"],
437
+ filtered_flowers["Site ID"],
438
+ filtered_flowers["Herb_abundance"],
439
+ filtered_flowers["Bryo_abundance"],
440
+ filtered_flowers["Woody_abundance"],
441
+ filtered_flowers["Veg_Spps"], # Herb richness
442
+ filtered_flowers["Bryo_Spps"], # Bryo richness
443
+ filtered_flowers["Woody_Spps"], # Woody richness
444
+ filtered_flowers["min_yield"],
445
+ filtered_flowers["max_yield"],
446
+ #we need to get ordinal_pos from filtered_for_plot, not filtered_flowers
447
+ filtered_flowers["Site ID"].map(filtered_for_plot.set_index("Site ID")["ordinal_pos"])
448
+ ):
449
+
450
+ #create position for site ids to draw circles, flowers etc.
451
+ cx = margin + (ord_pos/num_sites)*usable_width
452
+ cy = top_margin + margin + (y_max - yield_) / (y_max - y_min) * usable_height
453
+ cy_min = top_margin + margin + (y_max - min_y) / (y_max - y_min) * usable_height
454
+ cy_max = top_margin + margin + (y_max - max_y) / (y_max - y_min) * usable_height
455
+
456
+ #draw site ID name
457
+ _elements.append(
458
+ Text(x=cx, y= cy-10,
459
+ text=str(site_),
460
+ class_="axis-label", font_size=8)
461
+ )
462
+
463
+ #draw number of structure index per site ID at x-axis
464
+ _elements.append(
465
+ Text(x=cx-10-10, y=svg_height - margin +25,
466
+ text=f"{structure_:.2f}",
467
+ class_="axis-label", font_size=8,
468
+ transform=f"rotate(-45, {cx-10}, {svg_height - margin +15})")
469
+ )
470
+
471
+ #draw circles per site ID
472
+ _elements.append(
473
+ Circle(
474
+ cx=cx,
475
+ cy=cy,
476
+ r=3,
477
+ class_="nq1"
478
+ )
479
+ )
480
+
481
+
482
+ #DRAW MIN-MAX YIELD for three years - draw dashed line from min to max yield
483
+ _elements.append(
484
+ Line(
485
+ x1=cx, y1=cy_min,
486
+ x2=cx, y2=cy_max,
487
+ stroke="gray",
488
+ stroke_dasharray="3,3"
489
+ )
490
+ )
491
+ # - draw small square at max yield
492
+ _elements.append(
493
+ Rect(x=cx-3, y=cy_max-3, width=6, height=6, fill="gray")
494
+ )
495
+
496
+ # - draw small square at min yield
497
+ _elements.append(
498
+ Rect(x=cx-3, y=cy_min-3, width=6, height=6, fill="gray")
499
+ )
500
+
501
+
502
+ # each petal shows LENGTH = abundance, OPACITY = richness
503
+ #create three petals categories
504
+ petals = [
505
+ (90, herb_, "orange", herb_richness, herb_richness_min, herb_richness_max),
506
+ (210, bryo_, "blue", bryo_richness, bryo_richness_min, bryo_richness_max),
507
+ (330, woody_, "green", woody_richness, woody_richness_min, woody_richness_max),
508
+ ]
509
+
510
+ #draw ellipses based on petals data: correct direction, length corresponding abundance, opacity corresponding richness, and colour per group
511
+ for angle, abundance, color, richness, min_richness, max_richness in petals:
512
+ rad = math.radians(angle)
513
+ petal_length = abundance / 100 * 16 * flower_size.value # scale to fit in the plot, ABUNDANCE
514
+ opacity = get_opacity_from_richness(richness, min_richness, max_richness) # OPACITY = richness
515
+ ex = cx + math.sin(rad) * petal_length
516
+ ey = cy - math.cos(rad) * petal_length
517
+ _elements.append(
518
+ Ellipse(
519
+ cx=ex,
520
+ cy=ey,
521
+ rx=3*flower_size.value,
522
+ ry=petal_length,
523
+ fill=color,
524
+ opacity=opacity,
525
+ transform=f"rotate({angle}, {ex}, {ey})"
526
+ )
527
+ )
528
+
529
+
530
+ # ===== AXES ======
531
+ #creating variable 'axes'
532
+ _axes = []
533
+
534
+ # X-axis: draw the line of the x-axis and label it
535
+ _axes.append(
536
+ Line(
537
+ x1=margin,
538
+ y1=svg_height - margin,
539
+ x2=usable_width + margin,
540
+ y2=svg_height - margin,
541
+ stroke="black"
542
+ )
543
+ )
544
+ _axes.append(
545
+ Text(
546
+ x= usable_width + 100,
547
+ y=svg_height - margin + 22,
548
+ text="Sites ordered by structure index (1-3)",
549
+ class_="axis-title"
550
+ )
551
+ )
552
+
553
+ #Add ordinal positions on X-axis
554
+ for i in range(0, num_sites + 1, 1):
555
+ x = margin + (i / num_sites) * usable_width
556
+ _axes.append(
557
+ Line(x1=x, y1=svg_height - margin, x2= x, y2=svg_height - margin - 5, stroke="black")
558
+ )
559
+
560
+ # ===== HISTOGRAMS PER SITE =====
561
+ histogram_y = svg_height - 5
562
+ bar_width = 5
563
+ bar_spacing = 2 # Space between the 3 bars
564
+ bar_max_height = 40
565
+
566
+ _axes.append(
567
+ Text(
568
+ x=margin,
569
+ y=histogram_y - 40,
570
+ text="Cluster Distribution per Site (16 shrubs each)",
571
+ class_="axis-title"
572
+ )
573
+ )
574
+
575
+ # Colors for clusters
576
+ cluster_colors = {
577
+ '1': "#2d46dc", # Purple
578
+ '2': "#91d76e", # Green
579
+ '3': "#be2d32" # Red
580
+ }
581
+
582
+ # Draw histogram for each site in filtered_flowers
583
+ for site_id_ in filtered_flowers['Site ID'].values:
584
+ # Get ordinal position from filtered_for_plot
585
+ ord_pos_val = filtered_for_plot[filtered_for_plot['Site ID'] == site_id_]['ordinal_pos'].values[0]
586
+ site_x = margin + (ord_pos_val / num_sites) * usable_width
587
+
588
+ # Get cluster counts for this site
589
+ if site_id_ in cluster_counts.index:
590
+ counts = cluster_counts.loc[site_id_, ['1', '2', '3']]
591
+
592
+ # Draw 3 bars side-by-side
593
+ for cluster_idx, cluster in enumerate(['1', '2', '3']):
594
+ count = counts[cluster]
595
+ bar_height = (count / 16) * bar_max_height
596
+
597
+ # Calculate x position for each bar (3 bars side-by-side)
598
+ bar_x = site_x - (bar_width + bar_spacing) + cluster_idx * (bar_width + bar_spacing)
599
+
600
+ if bar_height > 0:
601
+ _axes.append(
602
+ Rect(
603
+ x=bar_x-2.5,
604
+ y=histogram_y - bar_height,
605
+ width=bar_width,
606
+ height=bar_height,
607
+ fill=cluster_colors[cluster]
608
+ )
609
+ )
610
+
611
+ # Y-axis: draw the line and label it
612
+ _axes.append(
613
+ Line(
614
+ x1=margin,
615
+ y1=top_margin + margin -15,
616
+ x2=margin,
617
+ y2=svg_height - margin,
618
+ stroke="black",
619
+ )
620
+ )
621
+
622
+ _axes.append(
623
+ Text(
624
+ x= margin,
625
+ y= top_margin + margin -23,
626
+ text="Mean coffee yield (kg/ha)",
627
+ class_="axis-title"
628
+ )
629
+ )
630
+
631
+ #Add manual arrow at top of y-axis
632
+ arrow_tip_x = margin
633
+ arrow_tip_y = top_margin + margin - 15
634
+ _axes.append(Line(x1=arrow_tip_x, y1=arrow_tip_y, x2=arrow_tip_x - 5, y2=arrow_tip_y + 10, stroke="black"))
635
+ _axes.append(Line(x1=arrow_tip_x, y1=arrow_tip_y, x2=arrow_tip_x + 5, y2=arrow_tip_y + 10, stroke="black"))
636
+
637
+ #Add positions on Y-axis
638
+ for val in [0, 500, 1000, 1500, 2000, 2500, 3000, 3500, 4000, 4500, 5000, 5500]:
639
+
640
+ y = top_margin + margin + (y_max - val) / (y_max - y_min) * usable_height
641
+
642
+ _axes.append(
643
+ Line(
644
+ x1=margin - 5,
645
+ y1=y,
646
+ x2=margin,
647
+ y2=y,
648
+ stroke="black"
649
+ )
650
+ )
651
+
652
+ _axes.append(
653
+ Text(
654
+ x=margin -50,
655
+ y=y + 5,
656
+ text=str(val),
657
+ class_="axis-label"
658
+ )
659
+ )
660
+
661
+ #Add dashed reference lines for Y-axis positions
662
+ # Make lines longer for 0 and 2000
663
+ if val in [500, 1000, 1500, 2000]:
664
+ x2_end = svg_width - 50 # Longer
665
+ else:
666
+ x2_end = usable_width + margin # Normal length
667
+
668
+ _axes.append(
669
+ Line(
670
+ x1=margin,
671
+ y1=y,
672
+ x2=x2_end,
673
+ y2=y,
674
+ stroke="lightgray",
675
+ stroke_dasharray="3,3",
676
+ opacity=0.7
677
+ )
678
+ )
679
+
680
+
681
+ # ===== TITLE ======
682
+ _axes.append(
683
+ Text(
684
+ x=svg_width / 2,
685
+ y= 50, # top_margin / 2 + 10,
686
+ text="Exploring Coffee Yield Patterns: Structure Index, Plant Abundance, and Plant Richness",
687
+ class_="main-title",
688
+ text_anchor="middle"
689
+ )
690
+ )
691
+ # Add subtitle
692
+ _axes.append(
693
+ Text(
694
+ x=svg_width / 2,
695
+ y= 75, #top_margin / 2 + 32,
696
+ text="Each flower represents a site; flower petals show abundance and richness of co-occuring plant species. Min-max lines indicate yield variation across 2017-2019.",
697
+ class_="subtitle",
698
+ text_anchor="middle"
699
+ )
700
+ )
701
+
702
+
703
+ # ===== LEGENDS =====
704
+
705
+ # ===== RIGHT SIDE =====
706
+
707
+ legend_x = usable_width + 120
708
+ legend_y = top_margin + margin
709
+
710
+ # ===== PART A: PLANT SPECIES LEGENDS =====
711
+
712
+ # ===== 1) PLANT SPECIES TYPE =====
713
+ _axes.append(
714
+ Text(
715
+ x=legend_x,
716
+ y=legend_y,
717
+ text="Plant Species Type",
718
+ class_="axis-title"
719
+ )
720
+ )
721
+
722
+ legend_colors = [
723
+ ("orange", "Herbaceous plant species"),
724
+ ("blue", "Bryophyte plant species"),
725
+ ("green", "Woody plant species"),
726
+ ]
727
+
728
+ for i, (color, label) in enumerate(legend_colors):
729
+ y_pos = legend_y + 20 + i * 18
730
+ _axes.append(
731
+ Ellipse(cx=legend_x, cy=y_pos, rx=5, ry=5, fill=color, opacity=0.6)
732
+ )
733
+ _axes.append(
734
+ Text(x=legend_x + 15, y=y_pos + 4, text=label, class_="axis-label")
735
+ )
736
+
737
+ # ===== 2) PETAL LENGTH = ABUNDANCE =====
738
+ legend_y_abundance = legend_y + 110
739
+
740
+ _axes.append(
741
+ Text(
742
+ x=legend_x,
743
+ y=legend_y_abundance,
744
+ text="Petal Length = Plant Abundance",
745
+ class_="axis-title"
746
+ )
747
+ )
748
+
749
+ _axes.append(
750
+ Text(
751
+ x=legend_x,
752
+ y=legend_y_abundance + 16,
753
+ text="(% of plant community)",
754
+ class_="axis-label",
755
+ font_size=8
756
+ )
757
+ )
758
+
759
+ # 5 petals showing abundance gradient with actual percentage values
760
+ abundance_values = [0, 25, 50, 75, 100]
761
+ petal_lengths = [2, 6, 10, 14, 18]
762
+ spacing = 50
763
+
764
+ for i, (abundance, petal_len) in enumerate(zip(abundance_values, petal_lengths)):
765
+ ex = legend_x + 5 + i * spacing
766
+ ey = legend_y_abundance + 40
767
+ _axes.append(
768
+ Ellipse(
769
+ cx=ex,
770
+ cy=ey,
771
+ rx=1.5,
772
+ ry=petal_len,
773
+ fill="gray",
774
+ opacity=0.3,
775
+ transform=f"rotate(90, {ex}, {ey})"
776
+ )
777
+ )
778
+
779
+ # Add value labels below
780
+ _axes.append(
781
+ Text(x=ex - 5, y=legend_y_abundance + 62, text=f"{abundance}%",
782
+ class_="axis-label", font_size=7)
783
+ )
784
+
785
+ # ===== 3) PETAL OPACITY = SPECIES RICHNESS =====
786
+ legend_y_richness = legend_y_abundance + 110
787
+
788
+ _axes.append(
789
+ Text(
790
+ x=legend_x,
791
+ y=legend_y_richness,
792
+ text="Petal Opacity = Species Richness",
793
+ class_="axis-title"
794
+ )
795
+ )
796
+
797
+ _axes.append(
798
+ Text(
799
+ x=legend_x,
800
+ y=legend_y_richness + 16,
801
+ text="(normalized 0.2-1.0 scale)",
802
+ class_="axis-label",
803
+ font_size=8
804
+ )
805
+ )
806
+
807
+ # 5 circles showing richness gradient with actual species counts
808
+ richness_values = [
809
+ (herb_richness_min, f"{int(herb_richness_min)} sp."),
810
+ ((herb_richness_min + herb_richness_max) * 0.25, f"{int((herb_richness_min + herb_richness_max) * 0.25)} sp."),
811
+ ((herb_richness_min + herb_richness_max) * 0.5, f"{int((herb_richness_min + herb_richness_max) * 0.5)} sp."),
812
+ ((herb_richness_min + herb_richness_max) * 0.75, f"{int((herb_richness_min + herb_richness_max) * 0.75)} sp."),
813
+ (herb_richness_max, f"{int(herb_richness_max)} sp."),
814
+ ]
815
+
816
+ opacities_richness = [0.2, 0.4, 0.6, 0.8, 1.0]
817
+
818
+ for i, (opacity, (richness_val, richness_label)) in enumerate(zip(opacities_richness, richness_values)):
819
+ ex = legend_x + 5 + i * spacing
820
+ ey = legend_y_richness + 40
821
+ _axes.append(
822
+ Ellipse(cx=ex, cy=ey, rx=5, ry=5, fill="gray", opacity=opacity)
823
+ )
824
+
825
+ # Add value labels below
826
+ _axes.append(
827
+ Text(x=ex - 8, y=legend_y_richness + 62, text=richness_label,
828
+ class_="axis-label", font_size=7)
829
+ )
830
+
831
+
832
+ # Frame around three Plant Species legends (Type, Abundance, Richness)
833
+ frame_padding = 12
834
+ _axes.append(
835
+ Rect(
836
+ x=legend_x - frame_padding,
837
+ y=legend_y - frame_padding,
838
+ width=320,
839
+ height=legend_y_richness + 100 - (legend_y - frame_padding),
840
+ fill="none",
841
+ stroke="#cccccc",
842
+ stroke_width=1.5,
843
+ opacity=0.9
844
+ )
845
+ )
846
+
847
+ # ===== STRUCTURE INDEX DENSITY LEGEND =====
848
+ density_legend_y = legend_y_richness + 145
849
+
850
+ #add title
851
+ _axes.append(
852
+ Text(
853
+ x=legend_x,
854
+ y=density_legend_y - 15,
855
+ text="Structure Index Density",
856
+ class_="axis-title"
857
+ )
858
+ )
859
+
860
+ # Create a vertical gradient scale showing gap size progression
861
+ gap_values = ["gap ≈ 0", "gap < 0.03", "gap < 0.06", "gap < 0.10", "gap ≥ 0.10"]
862
+ opacity_values = [0.35, 0.32, 0.25, 0.18, 0.10]
863
+
864
+ # Top label - High density
865
+ _axes.append(
866
+ Text(x=legend_x + 30, y=density_legend_y, text="High density (compressed)",
867
+ class_="axis-label", font_size=9)
868
+ )
869
+
870
+ # Draw rectangles vertically
871
+ for i, (gap, opacity) in enumerate(zip(gap_values, opacity_values)):
872
+ y_pos = density_legend_y + 10 + i * 22
873
+
874
+ _axes.append(
875
+ Rect(x=legend_x, y=y_pos, width=20, height=18, fill="gray", opacity=opacity)
876
+ )
877
+
878
+ _axes.append(
879
+ Text(x=legend_x + 28, y=y_pos + 13, text=gap,
880
+ class_="axis-label", font_size=9)
881
+ )
882
+
883
+ # Bottom label - Low density
884
+ _axes.append(
885
+ Text(x=legend_x + 30, y=density_legend_y + 10 + 5 * 22 + 15,
886
+ text="Low density (spread)", class_="axis-label", font_size=9)
887
+ )
888
+
889
+ # Frame around Structure Index Density legend
890
+ _axes.append(
891
+ Rect(
892
+ x=legend_x - frame_padding,
893
+ y= 430, #density_legend_y - frame_padding,
894
+ width=320,
895
+ height=5 * 22 + 60 +15,
896
+ fill="none",
897
+ stroke="#cccccc",
898
+ stroke_width=1.5,
899
+ opacity=0.9
900
+ )
901
+ )
902
+
903
+
904
+ # ===== CLUSTER LEGEND =====
905
+ cluster_legend_x = usable_width + 350
906
+ cluster_legend_y = histogram_y - 63
907
+
908
+ _axes.append(
909
+ Text(
910
+ x=cluster_legend_x -143,
911
+ y=cluster_legend_y +43,
912
+ text="Cluster Distribution",
913
+ class_="axis-title"
914
+ )
915
+ )
916
+
917
+ cluster_dataa = [
918
+ ("#2d46dc", "Cluster 1"),
919
+ ("#91d76e", "Cluster 2"),
920
+ ("#be2d32", "Cluster 3"),
921
+ ]
922
+
923
+ for i, (color, label) in enumerate(cluster_dataa):
924
+ y_pos = cluster_legend_y + 16 + i * 16
925
+ _axes.append(
926
+ Rect(x=cluster_legend_x, y=y_pos, width=10, height=10, fill=color)
927
+ )
928
+ _axes.append(
929
+ Text(x=cluster_legend_x + 18, y=y_pos + 10, text=label, class_="axis-label")
930
+ )
931
+
932
+
933
+
934
+ # ===== AGGREGATE FLOWERS (Bottom right area) =====
935
+
936
+ #create two groups
937
+ top_half = filtered_flowers.nlargest(len(filtered_flowers)//2, "Mean_CC_Yield")
938
+ bottom_half = filtered_flowers.nsmallest(len(filtered_flowers)//2, "Mean_CC_Yield")
939
+
940
+ # ABUNDANCE (for petal length)
941
+ g1_herb = bottom_half["Herb_abundance"].mean()
942
+ g1_bryo = bottom_half["Bryo_abundance"].mean()
943
+ g1_woody = bottom_half["Woody_abundance"].mean()
944
+
945
+ g2_herb = top_half["Herb_abundance"].mean()
946
+ g2_bryo = top_half["Bryo_abundance"].mean()
947
+ g2_woody = top_half["Woody_abundance"].mean()
948
+
949
+ # RICHNESS (for petal opacity)
950
+ g1_herb_richness = bottom_half["Veg_Spps"].mean()
951
+ g1_bryo_richness = bottom_half["Bryo_Spps"].mean()
952
+ g1_woody_richness = bottom_half["Woody_Spps"].mean()
953
+
954
+ g2_herb_richness = top_half["Veg_Spps"].mean()
955
+ g2_bryo_richness = top_half["Bryo_Spps"].mean()
956
+ g2_woody_richness = top_half["Woody_Spps"].mean()
957
+
958
+ #y positions fixed to mean yield of each group
959
+ flower_x = usable_width + 200
960
+ flower_y1 = top_margin + margin + (y_max - bottom_half["Mean_CC_Yield"].mean()) / (y_max - y_min) * usable_height #+800
961
+ flower_y2 = top_margin + margin + (y_max - top_half["Mean_CC_Yield"].mean()) / (y_max - y_min) * usable_height # + 900
962
+
963
+ #define draw_flower mentioning position, direction, abundance for two groups, colour etc
964
+ def draw_flower(cx, cy, herb, bryo, woody, herb_rich, bryo_rich, woody_rich, scale=1):
965
+ petals = [
966
+ (90, herb, "orange", herb_rich, herb_richness_min, herb_richness_max),
967
+ (210, bryo, "blue", bryo_rich, bryo_richness_min, bryo_richness_max),
968
+ (330, woody, "green", woody_rich, woody_richness_min, woody_richness_max),
969
+ ]
970
+ flower_elements = []
971
+ for angle, abundance, color, richness, min_richness, max_richness in petals:
972
+ rad = math.radians(angle)
973
+ petal_length = abundance / 100 * 14 * scale
974
+ opacity = get_opacity_from_richness(richness, min_richness, max_richness)
975
+ ex = cx + math.sin(rad) * petal_length
976
+ ey = cy - math.cos(rad) * petal_length
977
+ flower_elements.append(
978
+ Ellipse(
979
+ cx=ex,
980
+ cy=ey,
981
+ rx=3 * scale,
982
+ ry=petal_length,
983
+ fill=color,
984
+ opacity=opacity,
985
+ transform=f"rotate({angle}, {ex}, {ey})"
986
+ )
987
+ )
988
+ return flower_elements
989
+
990
+ # draw both aggregate flowers using definition
991
+ _elements += draw_flower(flower_x, flower_y1, g1_herb, g1_bryo, g1_woody, g1_herb_richness, g1_bryo_richness, g1_woody_richness, scale=3)
992
+ _elements += draw_flower(flower_x, flower_y2, g2_herb, g2_bryo, g2_woody, g2_herb_richness, g2_bryo_richness, g2_woody_richness, scale=3)
993
+
994
+ #add labels
995
+ _axes.append(
996
+ Text(
997
+ x=legend_x#flower_x-60
998
+ , y=density_legend_y +235,
999
+ text="Aggregate flowers of two groups comparing low/high yield",
1000
+ class_="axis-title"#,
1001
+ #font_size=6
1002
+ )
1003
+ )
1004
+ _axes.append(Text(
1005
+ x=legend_x #flower_x-60
1006
+ , y=flower_y1 - 60,
1007
+ text="Sites with low yield (Lower half of 60 sites/Bottom 10)", class_="axis-label"#, font_size=7
1008
+ ))
1009
+ _axes.append(Text(
1010
+ x=legend_x,
1011
+ #flower_x-60,
1012
+ y=flower_y2 -60,
1013
+ text="Sites with top yield (Upper half of 60 sites/Top 10)", class_="axis-label"#, font_size=7
1014
+ ))
1015
+
1016
+ # ===== DENSITY VISUALISATION BACKGROUND =====
1017
+ #add values of structure index in a list to calculate gaps
1018
+ struct_values = structureindex.values
1019
+
1020
+ for idx in range(len(struct_values) - 1):
1021
+ gap = struct_values[idx + 1] - struct_values[idx]
1022
+
1023
+ #size of gap determines opacity
1024
+ if gap == 0.0000:
1025
+ opacity = 0.35
1026
+ elif gap < 0.03:
1027
+ opacity = 0.32
1028
+ elif gap < 0.06:
1029
+ opacity = 0.25
1030
+ elif gap < 0.10:
1031
+ opacity = 0.18
1032
+ else:
1033
+ opacity = 0.10
1034
+
1035
+ #define positions for drawing rectangle (in between sites)
1036
+ x_curr = margin + (ordinal_pos[idx] / num_sites) * usable_width
1037
+ x_next = margin + (ordinal_pos[idx + 1] / num_sites) * usable_width
1038
+
1039
+ #draw rectangles between each site/structure index value, that span across the whole y-axis, using opacity variable to change according to gap size
1040
+ _axes.append(
1041
+ Rect(x=x_curr, y=margin+ top_margin, width=x_next - x_curr,
1042
+ height=usable_height, fill="gray", opacity=opacity)
1043
+ )
1044
+
1045
+ # ===== CREATING SVG FRAME =====
1046
+ _svg = SVG(width=svg_width, height=svg_height, class_="abc",
1047
+ elements=_elements+_axes)
1048
+ svg_str = _svg.as_str()
1049
+
1050
+ mo.vstack([
1051
+ mo.Html(svg_str),
1052
+ mo.hstack([
1053
+ filter_selector,
1054
+ flower_size
1055
+ ])
1056
+ ])
1057
+ return (
1058
+ abundance,
1059
+ abundance_values,
1060
+ angle,
1061
+ arrow_tip_x,
1062
+ arrow_tip_y,
1063
+ bar_height,
1064
+ bar_max_height,
1065
+ bar_spacing,
1066
+ bar_width,
1067
+ bar_x,
1068
+ bottom_half,
1069
+ bryo_,
1070
+ bryo_richness,
1071
+ cluster,
1072
+ cluster_colors,
1073
+ cluster_dataa,
1074
+ cluster_idx,
1075
+ cluster_legend_x,
1076
+ cluster_legend_y,
1077
+ color,
1078
+ count,
1079
+ counts,
1080
+ cx,
1081
+ cy,
1082
+ cy_max,
1083
+ cy_min,
1084
+ density_legend_y,
1085
+ draw_flower,
1086
+ ex,
1087
+ ey,
1088
+ flower_x,
1089
+ flower_y1,
1090
+ flower_y2,
1091
+ frame_padding,
1092
+ g1_bryo,
1093
+ g1_bryo_richness,
1094
+ g1_herb,
1095
+ g1_herb_richness,
1096
+ g1_woody,
1097
+ g1_woody_richness,
1098
+ g2_bryo,
1099
+ g2_bryo_richness,
1100
+ g2_herb,
1101
+ g2_herb_richness,
1102
+ g2_woody,
1103
+ g2_woody_richness,
1104
+ gap,
1105
+ gap_values,
1106
+ herb_,
1107
+ herb_richness,
1108
+ histogram_y,
1109
+ i,
1110
+ idx,
1111
+ label,
1112
+ legend_colors,
1113
+ legend_x,
1114
+ legend_y,
1115
+ legend_y_abundance,
1116
+ legend_y_richness,
1117
+ margin,
1118
+ max_richness,
1119
+ max_y,
1120
+ min_richness,
1121
+ min_y,
1122
+ num_sites,
1123
+ opacities_richness,
1124
+ opacity,
1125
+ opacity_values,
1126
+ ord_pos,
1127
+ ord_pos_val,
1128
+ petal_len,
1129
+ petal_length,
1130
+ petal_lengths,
1131
+ petals,
1132
+ rad,
1133
+ richness,
1134
+ richness_label,
1135
+ richness_val,
1136
+ richness_values,
1137
+ site_,
1138
+ site_id_,
1139
+ site_x,
1140
+ spacing,
1141
+ struct_values,
1142
+ structure_,
1143
+ svg_str,
1144
+ top_half,
1145
+ top_margin,
1146
+ usable_height,
1147
+ usable_width,
1148
+ val,
1149
+ woody_,
1150
+ woody_richness,
1151
+ x,
1152
+ x2_end,
1153
+ x_curr,
1154
+ x_max,
1155
+ x_min,
1156
+ x_next,
1157
+ y,
1158
+ y_max,
1159
+ y_min,
1160
+ y_pos,
1161
+ yield_,
1162
+ )
1163
+
1164
+
1165
+ if __name__ == "__main__":
1166
+ app.run()