diff --git a/community_gallery/earthquakes/hello.py b/community_gallery/earthquakes/hello.py index 6b1cb3da7..0197b46b5 100644 --- a/community_gallery/earthquakes/hello.py +++ b/community_gallery/earthquakes/hello.py @@ -3,7 +3,6 @@ from preswald import connect, get_df, plotly, slider, table, text - # Title text("# Earthquake Analytics Dashboard 🌍") @@ -49,6 +48,7 @@ # table(c_data) # table(d_data) + # --- # Slider for filtering magnitude @@ -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] @@ -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( @@ -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) diff --git a/community_gallery/travel/hello.py b/community_gallery/travel/hello.py index 14d24d134..c602636cd 100644 --- a/community_gallery/travel/hello.py +++ b/community_gallery/travel/hello.py @@ -3,7 +3,6 @@ from preswald import connect, get_df, plotly, slider, table, text - # Title text("# Travel Details Analytics Dashboard 🌍") @@ -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