-
Notifications
You must be signed in to change notification settings - Fork 0
/
fisher_visualizations.py
70 lines (60 loc) · 2.34 KB
/
fisher_visualizations.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import dash
from dash import dcc, html
import plotly.graph_objects as go
import pandas as pd
# Initialize the Dash app
app = dash.Dash(__name__)
app.title = "Interactive Visualizations"
# Generate Random Data for Ethnic Group Visualization
ethnic_data = pd.DataFrame({
"Group": ["White", "Black", "Asian", "Hispanic", "Other"],
"IQ": [110, 90, 105, 95, 100],
"Moral Character": [95, 85, 90, 80, 85],
"Violent Crime": [10, 50, 15, 40, 30],
"Income": [75, 45, 70, 50, 55],
"Reproduction Rate": [48, 55, 47, 60, 52]
})
# Generate Random Data for Environmental Impact Visualization
env_data = pd.DataFrame({
"Country": ["A", "B", "C", "D", "E"],
"CO2 Emissions": [50, 20, 40, 70, 30],
"GDP": [60, 30, 55, 20, 40],
"Renewable Energy": [15, 50, 20, 10, 30],
"Waste Generation": [80, 40, 70, 100, 50],
"Biodiversity Loss": [35, 60, 45, 70, 50]
})
# Ethnic Group Visualization
ethnic_fig = go.Figure()
for col in ["IQ", "Moral Character", "Violent Crime", "Income", "Reproduction Rate"]:
ethnic_fig.add_trace(go.Bar(x=ethnic_data["Group"], y=ethnic_data[col], name=col, opacity=0.75))
ethnic_fig.update_layout(title="Interactive Data Visualization: Ethnic Group Data",
barmode="group", plot_bgcolor="white", font_family="Avenir")
# Environmental Impact Visualization
env_fig = go.Figure()
for col in ["CO2 Emissions", "GDP", "Renewable Energy", "Waste Generation", "Biodiversity Loss"]:
env_fig.add_trace(go.Bar(x=env_data["Country"], y=env_data[col], name=col, opacity=0.75))
env_fig.update_layout(title="Interactive Data Visualization: Environmental Impact Data",
barmode="group", plot_bgcolor="white", font_family="Avenir")
# Layout for Dash Application
app.layout = html.Div([
html.Header([
html.H1("Interactive Visualizations"),
html.P("Explore and interact with the data visualizations below.")
]),
# Ethnic Group Data Visualization
html.Section([
html.H2("Ethnic Group Data"),
dcc.Graph(figure=ethnic_fig)
]),
# Environmental Impact Data Visualization
html.Section([
html.H2("Environmental Impact Data"),
dcc.Graph(figure=env_fig)
]),
html.Footer([
html.P("© 2024 Colin Geraghty. All rights reserved.")
])
])
# Run the Dash server
if __name__ == "__main__":
app.run_server(debug=True)