Last active
May 15, 2019 11:09
-
-
Save ebergam/38428e5c4b24eb91dec2006927e96281 to your computer and use it in GitHub Desktop.
Moving Scatter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
graph = px.scatter(df, x="employment", y="equity", #color="country", | |
hover_name="country", text="countrycode", | |
range_x=[48,80], range_y=[76,93], template="plotly_dark", size="pop", | |
animation_group="country", animation_frame="year", | |
labels=dict(employment="Emp", equity="Eq",year="Year")) | |
for i in graph['data']: | |
i['name'] = i['name'].replace('Country=', '') | |
quadrant_shapes = { | |
'shapes': [ | |
{ | |
'type': 'rect', | |
# x-reference is assigned to the x-values | |
'xref': 'x', | |
# y-reference is assigned to the plot paper [0,1] | |
'yref': 'paper', | |
'x0': 65.15, | |
'y0': 0, | |
'x1': 65.25, | |
'y1': 1, | |
'fillcolor': '#ffffff', | |
'opacity': 0.7, | |
'line': { | |
'width': 0, | |
} | |
}, | |
{ | |
'type': 'rect', | |
'xref': 'paper', | |
'yref': 'y', | |
'x0': 0, | |
'y0': 84.75, | |
'x1': 1, | |
'y1': 84.85, | |
'fillcolor': '#ffffff', | |
'opacity': 0.7, | |
'line': { | |
'width': 0, | |
} | |
}, | |
] | |
} | |
#graph.frames[0].update(cc) | |
graph.layout.update(quadrant_shapes) | |
graph.layout.xaxis.update(dict(showgrid=False)) | |
graph.layout.yaxis.update(dict(showgrid=False)) | |
graph |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment