Skip to content

Fix: Cleanup of example apps and tutorial, added axis labels. #714

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions community_gallery/earthquakes/hello.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

from preswald import connect, get_df, plotly, slider, table, text


# Title
text("# Earthquake Analytics Dashboard 🌍")

Expand Down Expand Up @@ -49,6 +48,7 @@

# table(c_data)
# table(d_data)

# ---

# Slider for filtering magnitude
Expand All @@ -57,7 +57,6 @@
# Read the data and filter based on magnitude
data = get_df("earthquake_data")
# data = get_df("earthquake_db", "earthquake_data") # NOTE: requires changing the column names based on what you have in postgres
# Convert Magnitude column to numeric, handling any non-numeric values
data["Magnitude"] = pd.to_numeric(data["Magnitude"], errors="coerce")
filtered_data = data[data["Magnitude"] >= min_magnitude]

Expand All @@ -67,7 +66,6 @@
# Summary statistics
text(f"### Total Earthquakes with Magnitude ≥ {min_magnitude}: {len(filtered_data)}")


# Interactive map using Plotly
text("## Earthquake Locations")
fig_map = px.scatter_geo(
Expand All @@ -83,7 +81,14 @@

# Magnitude distribution
fig_hist = px.histogram(
filtered_data, x="Magnitude", nbins=20, title="Distribution of Magnitudes"
filtered_data,
x="Magnitude",
nbins=20,
title="Distribution of Magnitudes"
)
fig_hist.update_layout( # 🆕 Add x/y axis labels
xaxis_title="Magnitude",
yaxis_title="Number of Earthquakes"
)
plotly(fig_hist)

Expand Down
5 changes: 4 additions & 1 deletion community_gallery/travel/hello.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

from preswald import connect, get_df, plotly, slider, table, text


# Title
text("# Travel Details Analytics Dashboard 🌍")

Expand Down Expand Up @@ -81,6 +80,10 @@ def clean_cost(cost):
nbins=20,
title="Distribution of Accommodation Cost",
)
fig_hist.update_layout( # ✅ Added axis titles for Issue #656
xaxis_title="Accommodation Cost (USD)",
yaxis_title="Number of Trips"
)
plotly(fig_hist)

# Nationality vs. Accommodation cost scatter plot
Expand Down