From ba03a3becbb1096a399f1f241ea15a80a6c49b8d Mon Sep 17 00:00:00 2001 From: Sagar Manna Date: Fri, 20 Jun 2025 10:14:40 +0530 Subject: [PATCH] Added interactive dashboard built with Preswald --- data/sample.csv | 11 ++++++ hello.py | 83 +++++++++++++++++++++++++++++++++++++++++++++ images/favicon.ico | Bin 0 -> 240 bytes images/logo.png | Bin 0 -> 613 bytes preswald.toml | 20 +++++++++++ secrets.toml | 2 ++ 6 files changed, 116 insertions(+) create mode 100644 data/sample.csv create mode 100644 hello.py create mode 100644 images/favicon.ico create mode 100644 images/logo.png create mode 100644 preswald.toml create mode 100644 secrets.toml diff --git a/data/sample.csv b/data/sample.csv new file mode 100644 index 000000000..6adab346b --- /dev/null +++ b/data/sample.csv @@ -0,0 +1,11 @@ +decimalLatitude,decimalLongitude,speciesQueried,country,year,lifeStage +-3.4653,-62.2159,Callithrix jacchus,Brazil,2018,Adult +-4.2121,-63.0012,Callithrix penicillata,Brazil,2019,Juvenile +5.0000,-74.0000,Cebuella pygmaea,Colombia,2017,Adult +-1.4563,-78.9874,Leontopithecus rosalia,Ecuador,2020,Subadult +-12.4634,-55.6658,Saguinus oedipus,Brazil,2016,Adult +2.0500,-75.2500,Saguinus mystax,Colombia,2021,Juvenile +-9.1900,-67.8280,Leontopithecus chrysomelas,Brazil,2015,Adult +0.0000,-60.0000,Callithrix geoffroyi,Venezuela,2019,Subadult +4.5709,-74.2973,Cebuella pygmaea,Colombia,2022,Adult +-15.7797,-47.9297,Callithrix jacchus,Brazil,2023,Juvenile diff --git a/hello.py b/hello.py new file mode 100644 index 000000000..4f191c861 --- /dev/null +++ b/hello.py @@ -0,0 +1,83 @@ +import pandas as pd +import plotly.express as px +import preswald + +# Load dataset +df = pd.read_csv('data/sample.csv') + +# Geographic Scatter Plot +fig = px.scatter_geo( + df, + lat="decimalLatitude", + lon="decimalLongitude", + hover_name="speciesQueried", + color="country", + title="Geographical Distribution of Callitrichidae Specimens", + projection="natural earth" +) + +# Density Heatmap +hotspot_map = px.density_mapbox( + df, + lat="decimalLatitude", + lon="decimalLongitude", + radius=8, + zoom=3, + color_continuous_scale="Viridis", + mapbox_style="carto-positron", + title="Spatial Density Analysis of Callitrichidae Populations" +) + +# Species Richness Bar Chart +richness = df.groupby("country")["speciesQueried"].nunique().reset_index(name="richness") +richness_plot = px.bar( + richness.sort_values("richness", ascending=False), + x="country", + y="richness", + title="Callitrichidae Species Richness by Geographic Region" +) + +# Hierarchical Distribution TreeMap +df_treemap = df.groupby(["country", "speciesQueried"]).size().reset_index(name="count") +treemap_plot = px.treemap( + df_treemap, + path=["country", "speciesQueried"], + values="count", + color="count", + title="Taxonomic and Geographic Distribution of Callitrichidae Specimens" +) + +# Life Stage Trend Line Plot +life_stage_trend = df[df["lifeStage"].notna() & (df["lifeStage"].str.lower() != "unknown")] +life_stage_plot_data = life_stage_trend.groupby(["year", "lifeStage"]).size().reset_index(name="count") +life_stage_plot = px.line( + life_stage_plot_data, + x="year", + y="count", + color="lifeStage", + title="Ontogenetic Distribution of Callitrichidae Observations: Temporal Analysis" +) + +# ───────────────────── Display on Preswald UI ───────────────────── + +preswald.text("# 🐒 Biogeographical Analysis of Callitrichidae Distribution Patterns") + +preswald.text("## 📍 Spatial Distribution Analysis") +preswald.text("Figure 1 shows the global locations of documented Callitrichidae specimens by country.") +preswald.plotly(fig) + +preswald.text("## 🌐 Population Density Assessment") +preswald.text("Figure 2 estimates specimen density and helps identify biodiversity hotspots.") +preswald.plotly(hotspot_map) + +preswald.text("## 🌱 Species Richness Evaluation") +preswald.text("Figure 3 shows how many unique species were observed per country.") +preswald.plotly(richness_plot) + +preswald.text("## 🧬 Taxonomic Distribution by Region") +preswald.text("Figure 4 illustrates taxonomic and geographic spread using a hierarchical treemap.") +preswald.plotly(treemap_plot) + +preswald.text("## 📈 Ontogenetic Temporal Distribution") +preswald.text("Figure 5 tracks specimen counts by life stage over time.") +preswald.plotly(life_stage_plot) diff --git a/images/favicon.ico b/images/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..5a7871528b1237217416ab310f331e22386e376a GIT binary patch literal 240 zcmVPx#s!2paR5(wylTi|bAPht|Tugg1+mlr<2JJG9jUlMxjQL`KyewfO_{S5#0AMtG z(Q*c`d=GdZ^1JaqN)!>4QY?_52LU8a_9VF66ZInCu)0=GDK#nx*yxH%DS*m+tN<%p z*L#Ty+Es8F;1eT|s;mlp*Utd%eS*@hlBmh*#O52%G|xU^V(-<=QU(8`gS qI`*zsW;80?;Pj@l4wJ^EasB}A`dx?opKqN20000=txc@i%?P*Rx6QC#V(7IZ()SoKr@fnvC;rwpX=hO}l@Ao!TZtoOCv literal 0 HcmV?d00001 diff --git a/preswald.toml b/preswald.toml new file mode 100644 index 000000000..be86e1824 --- /dev/null +++ b/preswald.toml @@ -0,0 +1,20 @@ +[project] +title = "Preswald Project" +version = "0.1.0" +port = 8501 +slug = "my-app-839952" +entrypoint = "hello.py" + +[branding] +name = "Preswald Project" +logo = "images/logo.png" +favicon = "images/favicon.ico" +primaryColor = "#F89613" + +[data.sample_csv] +type = "csv" +path = "data/sample.csv" + +[logging] +level = "INFO" +format = "%(asctime)s - %(name)s - %(levelname)s - %(message)s" diff --git a/secrets.toml b/secrets.toml new file mode 100644 index 000000000..688f4e3ca --- /dev/null +++ b/secrets.toml @@ -0,0 +1,2 @@ +# Store your sensitive configuration here +# This file is gitignored by default \ No newline at end of file