Skip to content

Commit

Permalink
interactive plots update
Browse files Browse the repository at this point in the history
  • Loading branch information
iretes committed Nov 2, 2023
1 parent f2c41a4 commit c58f78f
Show file tree
Hide file tree
Showing 6 changed files with 242 additions and 6 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# USA_gun_incidents

## Data visualization
This repository hosts also interactive data visualizations. You can access and interact with the plots by clicking the links below.

### Plots

1. [Correlation between poverty and number of mortal incidents](html/scatter_poverty.html)
- [Animation of the poverty percentage over the years](html/animation_poverty.html)
- [Poverty percentage trends over the years](html/lines_poverty.html)
- [Animation of the results of the House of Representatives elections over the years](html/animation_elections.html)
- [Correlation between poverty and number of mortal incidents](html/scatter_poverty.html)
9 changes: 6 additions & 3 deletions TASK_1/Task_1.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import seaborn as sns
import matplotlib.dates as mdates
import plotly.express as px
import plotly.offline as pyo
import math
import os
import calendar
Expand Down Expand Up @@ -209,6 +210,7 @@
fig = px.line(
poverty_df.pivot(index='year', columns='state', values='povertyPercentage'),
title='Poverty percentage in the US over the years')
pyo.plot(fig, filename='../html/lines_poverty.html', auto_open=False)
fig.show()

# %% [markdown]
Expand Down Expand Up @@ -242,6 +244,7 @@
title_text='US Poverty Percentage over the years',
coloraxis_colorbar_title_text = 'Poverty (%)'
)
pyo.plot(fig, filename='../html/animation_poverty.html', auto_open=False)
fig.show()

# %%
Expand Down Expand Up @@ -553,6 +556,7 @@
fig.update_layout(
legend_title_text='Party'
)
pyo.plot(fig, filename='../html/animation_elections.html', auto_open=False)
fig.show()

# %% [markdown]
Expand Down Expand Up @@ -2576,11 +2580,10 @@ def max_min_value(attribute): # FIX: convertire in float, escludere <= 122 e > 0
facet_col="year",
facet_col_wrap=3
)
pyo.plot(fig, filename='../html/scatter_poverty.html', auto_open=False)
fig.show()

# %%
import plotly.offline as pyo
pyo.plot(fig, filename='../html/scatter_poverty.html', auto_open=False)


# %% [markdown]
# ## Incident characteristics features: exploration and preparation
Expand Down
11 changes: 11 additions & 0 deletions _config.yml
Original file line number Diff line number Diff line change
@@ -1 +1,12 @@
title: USA gun incidents
description: This project has been developed for the "Data mining" course at the University of Pisa.
authors:
aru:
name: Giacomo Aru
ghisolfi:
name: Giulia Ghisolfi
marini:
name: Luca Marini
testa:
name: Irene Testa
theme: minima
75 changes: 75 additions & 0 deletions html/animation_elections.html

Large diffs are not rendered by default.

75 changes: 75 additions & 0 deletions html/animation_poverty.html

Large diffs are not rendered by default.

71 changes: 71 additions & 0 deletions html/lines_poverty.html

Large diffs are not rendered by default.

0 comments on commit c58f78f

Please sign in to comment.