Skip to content

Commit a974765

Browse files
Update plot scale
1 parent 3115d92 commit a974765

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

src/app.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878

7979
scatter_plot_card=dbc.Card(
8080
dbc.CardBody(
81-
[html.H6('Top 10 Countries\' Total Deaths by Earthquake Magnitude', className='card-title',
81+
[html.H6('Total Deaths and Earthquake Magnitude per Event', className='card-title',
8282
style={'margin-bottom': '0px'}),
8383
html.Iframe(
8484
id='scatter_plot',
@@ -198,4 +198,4 @@ def toggle_navbar_collapse(n, is_open):
198198
return is_open
199199

200200
if __name__ == '__main__':
201-
app.run_server()
201+
app.run_server(debug=True)

src/components/map_plot.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ def create_map_plot(year_start, year_end, countries):
6565
orient='top-left')),
6666
tooltip=[alt.Tooltip("earthquake_magnitude",
6767
title="Earthquake Magnitude")]
68-
).properties(width=300, height=100)
68+
)
69+
.properties(width=300, height=100)
6970
)
7071

7172
return (map + tsunami_spots).to_html()

src/components/scatter_plot.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,25 @@ def create_scatter_plot(year_start=1900, year_end=2022, countries=[]):
3232
scatter plot chart of earthquake intensity versus total deaths
3333
recorded (on a log-scale)
3434
"""
35-
chart = alt.Chart(get_data(year_start, year_end, countries)
36-
).mark_point(opacity=0.65, size=20).encode(
35+
chart = alt.Chart(
36+
get_data(year_start, year_end, countries)
37+
).mark_point(opacity=0.65, size=20).encode(
3738
x=alt.X('earthquake_magnitude',
3839
title='Earthquake Magnitude (Richter Scale)',
3940
scale=alt.Scale(domain=(5.5, 10)),
4041
axis=alt.Axis(grid=False)),
4142
y=alt.Y('total_deaths',
4243
title='Total Deaths (log-scale), per Event',
43-
scale=alt.Scale(type='log')),
44-
color='country',
44+
scale=alt.Scale(type='log', domainMin=0.1),
45+
axis=alt.Axis(
46+
labelColor=alt.condition(
47+
'datum.value < 1',
48+
alt.value('white'),
49+
alt.value('black')
50+
)
51+
)),
52+
color=alt.Color('country',
53+
legend=alt.Legend(title="Countries (up to Top 10)")),
4554
tooltip=['year', 'mercalli_intensity', 'country', 'total_deaths']
4655
).interactive(
4756
).properties(

0 commit comments

Comments
 (0)