In [ ]:
import plotly.plotly as py
import plotly.graph_objs as go
import plotly.offline as offline
offline.init_notebook_mode(connected=False)
trace1 = {"x": [72, 67, 73, 80, 76, 79, 84, 78, 86, 93, 94, 90, 92, 96, 94, 112],
"y": ["Brown", "NYU", "Notre Dame", "Cornell", "Tufts", "Yale",
"Dartmouth", "Chicago", "Columbia", "Duke", "Georgetown",
"Princeton", "U.Penn", "Stanford", "MIT", "Harvard"],
"marker": {"color": "pink", "size": 12},
"mode": "markers",
"name": "Women",
"type": "scatter"
}
trace2 = {"x": [92, 94, 100, 107, 112, 114, 114, 118, 119, 124, 131, 137, 141, 151, 152, 165],
"y": ["Brown", "NYU", "Notre Dame", "Cornell", "Tufts", "Yale",
"Dartmouth", "Chicago", "Columbia", "Duke", "Georgetown",
"Princeton", "U.Penn", "Stanford", "MIT", "Harvard"],
"marker": {"color": "blue", "size": 12},
"mode": "markers",
"name": "Men",
"type": "scatter",
}
data = [trace1, trace2]
layout = {"title": "Gender Earnings Disparity",
"xaxis": {"title": "Annual Salary (in thousands)", },
"yaxis": {"title": "School"}}
fig = go.Figure(data=data, layout=layout)
# py.iplot(fig, filenmae='basic_dot-plot')
offline.iplot(fig)
In [ ]:
import plotly.plotly as py
import plotly.graph_objs as go
import plotly.offline as offline
offline.init_notebook_mode(connected=False)
country = ['Switzerland (2011)', 'Chile (2013)', 'Japan (2014)',
'United States (2012)', 'Slovenia (2014)', 'Canada (2011)',
'Poland (2010)', 'Estonia (2015)', 'Luxembourg (2013)', 'Portugal (2011)']
voting_pop = [40, 45.7, 52, 53.6, 54.1, 54.2, 54.5, 54.7, 55.1, 56.6]
reg_voters = [49.1, 42, 52.7, 84.3, 51.7, 61.1, 55.3, 64.2, 91.1, 58.9]
trace0 = go.Scatter(
x=voting_pop,
y=country,
mode='markers',
name='Percent of estimated voting age population',
marker=dict(
color='rgba(156, 165, 196, 0.95)',
line=dict(
color='rgba(156, 165, 196, 1.0)',
width=1,
),
# symbol='circle',
# symbol='circle-dot',
# symbol='circle-open-dot',
# symbol='square',
# symbol='diamond',
symbol='cross',
size=16,
)
)
trace1 = go.Scatter(
x=reg_voters,
y=country,
mode='markers',
name='Percent of estimated registered voters',
marker=dict(
color='rgba(204, 204, 204, 0.95)',
line=dict(
color='rgba(217, 217, 217, 1.0)',
width=1,
),
symbol='circle',
size=16,
)
)
data = [trace0, trace1]
layout = go.Layout(
title="Votes cast for ten lowest voting age population in OECD countries",
xaxis=dict(
showgrid=False,
showline=True,
linecolor='rgb(102, 102, 102)',
titlefont=dict(
color='rgb(204, 204, 204)'
),
tickfont=dict(
color='rgb(102, 102, 102)',
),
showticklabels=True,
dtick=10,
ticks='outside',
tickcolor='rgb(102, 102, 102)',
),
margin=dict(
l=140,
r=40,
b=50,
t=80
),
legend=dict(
font=dict(
size=10,
),
yanchor='middle',
xanchor='right',
),
width=800,
height=600,
paper_bgcolor='rgb(254, 247, 234)',
plot_bgcolor='rgb(254, 247, 234)',
hovermode='closest',
)
fig = go.Figure(data=data, layout=layout)
# py.iplot(fig, filename='lowest-oecd-votes-cast')
offline.iplot(fig)
コメント