In [1]:
import pandas as pd
import numpy as np
import plotly.plotly as py
import plotly.graph_objs as go
wealth = pd.read_csv('https://raw.githubusercontent.com/democratia/political_science/master/Daten/vermoegensverteilung.csv', sep=",")
print(wealth[0:1])
wealth = wealth.sort_values("Anteil Vermögen")
bar_layout=dict(
color='rgb(255, 161, 0)'
)
tr = go.Bar(
x=wealth["Kanton"],
y=wealth["Anteil Vermögen"],
text="",
name="",
marker=bar_layout
)
layout = go.Layout(
title='Anteil der Superreichen am Gesamtvermögen',
xaxis=dict(title='Kanton'),
yaxis=dict(title='Anteil am Gesamtvermögen (in Prozent)'),
)
trace = [tr]
fig = go.Figure(data=trace, layout=layout)
py.iplot(fig, filename='anteil-vermoegen')
Out[1]:
In [22]:
wealth = wealth.sort_values("Durchschnittsvermögen")
tr = go.Bar(
x=wealth["Kanton"],
y=wealth["Durchschnittsvermögen"],
text="",
name="",
marker=bar_layout
)
layout = go.Layout(
title='Durchschnittsvermögen der Superreichen',
xaxis=dict(title='Kanton'),
yaxis=dict(title='Durchschnittsvermögen (in Millionen)'),
)
trace = [tr]
fig = go.Figure(data=trace, layout=layout)
py.iplot(fig, filename='durchschnitt-vermoegen')
Out[22]:
In [23]:
wealth = wealth.sort_values("Anteil Personen")
tr = go.Bar(
x=wealth["Kanton"],
y=wealth["Anteil Personen"],
text="",
name="",
marker=bar_layout
)
layout = go.Layout(
title='Anteil der Superreichen an der Gesamtbevölkerung',
xaxis=dict(title='Kanton'),
yaxis=dict(title='Anteil (in Prozent)'),
)
trace = [tr]
fig = go.Figure(data=trace, layout=layout)
py.iplot(fig, filename='superreiche-bevoelkerung')
Out[23]:
In [2]:
wealth = wealth.sort_values("Kein Vermögen")
tr = go.Bar(
x=wealth["Kanton"],
y=wealth["Kein Vermögen"],
text="",
name="",
marker=bar_layout
)
layout = go.Layout(
title='Anteil der Bevölkerung ohne Vermögen',
xaxis=dict(title='Kanton'),
yaxis=dict(title='Anteil (in Prozent)'),
)
trace = [tr]
fig = go.Figure(data=trace, layout=layout)
py.iplot(fig, filename='bevoelkerung-ohne-vermoegen')
Out[2]:
In [4]:
trace = go.Scatter(
x = wealth["Kein Vermögen"],
y = wealth["Anteil Personen"],
mode = 'markers',
#text=kantonsnamen,
marker = dict(
size = 20,
color = 'rgba(255, 161, 0, 1.0)',
line = dict(
width = 2,
)
),
)
layout = go.Layout(
hovermode = 'closest',
title='Ohne Vermögen vs Superreiche',
xaxis=dict(title='Anteil ohne Vermögen (in Prozent)'),
yaxis=dict(title='Anteil Superreiche (in Prozent)')
)
data = [trace]
fig = go.Figure(data=data, layout=layout)
py.iplot(fig, filename='superrich-vs-no-wealth')
Out[4]:
In [ ]: