summaryrefslogtreecommitdiff
path: root/fun_tools
diff options
context:
space:
mode:
authorzhang <zch921005@126.com>2022-07-24 20:25:48 +0800
committerzhang <zch921005@126.com>2022-07-24 20:25:48 +0800
commit92d3bc06bad13095df6515111bba45e73f701018 (patch)
tree5730478fe92b39f3b909843546291d0eced774d0 /fun_tools
parente9945ee44d8c46d93d50f023f49e79f3ba532583 (diff)
wordpiece
Diffstat (limited to 'fun_tools')
-rw-r--r--fun_tools/bar_animation.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/fun_tools/bar_animation.py b/fun_tools/bar_animation.py
new file mode 100644
index 0000000..bff49d7
--- /dev/null
+++ b/fun_tools/bar_animation.py
@@ -0,0 +1,35 @@
+import bar_chart_race as bcr
+df = bcr.load_dataset('covid19_tutorial')
+bcr.bar_chart_race(
+ df=df,
+ filename='./images/covid19_horiz.mp4',
+ orientation='v',
+ sort='desc',
+ n_bars=8,
+ fixed_order=False,
+ fixed_max=True,
+ steps_per_period=20,
+ period_length=500,
+ # end_period_pause=0,
+ interpolate_period=False,
+ period_label={'x': .98, 'y': .3, 'ha': 'right', 'va': 'center'},
+ # period_template='%B %d, %Y',
+ period_summary_func=lambda v, r: {'x': .98, 'y': .2,
+ 's': f'Total deaths: {v.sum():,.0f}',
+ 'ha': 'right', 'size': 11},
+ perpendicular_bar_func='median',
+ # colors='dark12',
+ title='COVID-19 Deaths by Country',
+ bar_size=.95,
+ # bar_textposition='inside',
+ # bar_texttemplate='{x:,.0f}',
+ # bar_label_font=7,
+ # tick_label_font=7,
+ # tick_template='{x:,.0f}',
+ shared_fontdict=None,
+ scale='linear',
+ fig=None,
+ writer=None,
+ bar_kwargs={'alpha': .7},
+ # fig_kwargs={'figsize': (6, 3.5), 'dpi': 144},
+ filter_column_colors=False) \ No newline at end of file