Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
CSDN 技术社区
topn_race
提交
627a98e4
T
topn_race
项目概览
CSDN 技术社区
/
topn_race
通知
454
Star
15
Fork
18
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
topn_race
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
627a98e4
编写于
12月 29, 2021
作者:
F
feilong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
添加DEMO
上级
e05921c2
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
6 addition
and
51 deletion
+6
-51
README.md
README.md
+4
-4
demo/csdn_ask_top10_month.gif
demo/csdn_ask_top10_month.gif
+0
-0
demo/csdn_trends_top10_month.gif
demo/csdn_trends_top10_month.gif
+0
-0
main.py
main.py
+2
-2
src/bar_chart_race/chart.py
src/bar_chart_race/chart.py
+0
-45
未找到文件。
README.md
浏览文件 @
627a98e4
...
...
@@ -19,9 +19,9 @@ python main.py
## 例子
###
CSDN 问答2008-2021 月top10标签竞赛图
###
DEMO CSDN 问答2008-2021 月top10标签竞赛图片段
![](
./
pub/tags_top10_month_ask.mp4
)
###
CSDN 指数趋势 2000-2021 月top10标签竞赛图
![](
./
demo/csdn_ask_top10_month.gif
)
###
DEMO CSDN 指数趋势 2000-2021 月top10标签竞赛图片段
![](
./pub/trands_top10_month.mp4
)
\ No newline at end of file
![](
./demo/csdn_trends_top10_month.gif
)
\ No newline at end of file
demo/csdn_ask_top10_month.gif
0 → 100644
浏览文件 @
627a98e4
4.9 MB
demo/csdn_trends_top10_month.gif
0 → 100644
浏览文件 @
627a98e4
445.3 KB
main.py
浏览文件 @
627a98e4
...
...
@@ -32,11 +32,11 @@ def test_build_csdn_trend_top10_tag_race():
)
output
=
OutputMeta
(
path
=
'pub/csdn_trends_top10_month.
gif
'
,
path
=
'pub/csdn_trends_top10_month.
mp4
'
,
title
=
'CSDN topN指数月排行榜'
,
x_label
=
'csdn.net/trends'
,
y_label
=
'指数'
,
month_count
=
12
month_count
=
None
)
top
=
Top
(
input
,
output
)
...
...
src/bar_chart_race/chart.py
浏览文件 @
627a98e4
...
...
@@ -273,7 +273,6 @@ class BarChartRace:
ax
.
minorticks_off
()
ax
.
set_axisbelow
(
True
)
ax
.
tick_params
(
length
=
0
,
labelsize
=
self
.
tick_label_size
,
pad
=
2
)
# ax.set_facecolor('.97')
ax
.
set_title
(
self
.
title
,
size
=
self
.
title_size
,
loc
=
'left'
,
weight
=
800
)
for
spine
in
ax
.
spines
.
values
():
spine
.
set_visible
(
False
)
...
...
@@ -285,7 +284,6 @@ class BarChartRace:
ax
=
fig
.
add_subplot
()
fake_cols
=
[
chr
(
i
+
70
)
for
i
in
range
(
self
.
df_values
.
shape
[
1
])]
max_val
=
self
.
df_values
.
max
().
max
()
# min_val = 1 if self.scale == 'log' else 0
if
self
.
orientation
==
'h'
:
ax
.
barh
(
fake_cols
,
[
1
]
*
self
.
df_values
.
shape
[
1
])
ax
.
tick_params
(
labelrotation
=
0
,
axis
=
'y'
,
...
...
@@ -375,7 +373,6 @@ class BarChartRace:
ha
=
'right'
,
color
=
'#262525'
,
size
=
14
,
# bbox=dict(facecolor='white', alpha=0.95, edgecolor='white')
)
self
.
ax
.
text
(
...
...
@@ -385,21 +382,8 @@ class BarChartRace:
ha
=
'right'
,
color
=
'#262525'
,
size
=
16
,
# bbox=dict(facecolor='white', alpha=0.95, edgecolor='white')
)
# self.ax.set_yticks([]) # 隐藏Y轴标签
# if self.period_summary_func:
# values = self.df_values.iloc[i]
# ranks = self.df_ranks.iloc[i]
# text_dict = self.period_summary_func(values, ranks)
# if 'x' not in text_dict or 'y' not in text_dict or 's' not in text_dict:
# name = self.period_summary_func.__name__
# raise ValueError(f'The dictionary returned from `{name}` must contain '
# '"x", "y", and "s"')
# self.ax.text(transform=self.ax.transAxes, **text_dict)
if
self
.
label_bars
:
if
self
.
orientation
==
'h'
:
zipped
=
zip
(
bar_length
,
bar_location
)
...
...
@@ -410,53 +394,24 @@ class BarChartRace:
for
x1
,
y1
in
zipped
:
xtext
,
ytext
=
self
.
ax
.
transLimits
.
transform
((
x1
,
y1
))
# xkey = xtext
# ykey = ytext
if
self
.
orientation
==
'h'
:
xtext
+=
.
01
# xkey -= 0.2
text
=
f
'
{
x1
:,.
0
f
}
'
rotation
=
0
ha
=
'left'
va
=
'center'
else
:
ytext
+=
.
015
# ykey -= 0.2
text
=
f
'
{
y1
:,.
0
f
}
'
rotation
=
90
ha
=
'center'
va
=
'bottom'
xtext
,
ytext
=
self
.
ax
.
transLimits
.
inverted
().
transform
((
xtext
,
ytext
))
# xkey, ykey = self.ax.transLimits.inverted().transform((xkey, ykey))
text
=
self
.
ax
.
text
(
xtext
,
ytext
,
text
,
ha
=
ha
,
rotation
=
rotation
,
fontsize
=
self
.
bar_label_size
,
weight
=
600
,
va
=
va
)
# text_label = bar_keys[i]+":"+text
# self.ax.text(xkey, ykey, text_label, ha=ha, rotation=rotation,
# fontsize=self.bar_label_size, weight=600, va=va)
i
+=
1
# if self.perpendicular_bar_func:
# if isinstance(self.perpendicular_bar_func, str):
# val = pd.Series(bar_length).agg(self.perpendicular_bar_func)
# else:
# values = self.df_values.iloc[i]
# ranks = self.df_ranks.iloc[i]
# val = self.perpendicular_bar_func(values, ranks)
# if not self.ax.lines:
# if self.orientation == 'h':
# self.ax.axvline(val, lw=10, color='.5', zorder=.5)
# else:
# self.ax.axhline(val, lw=10, color='.5', zorder=.5)
# else:
# line = self.ax.lines[0]
# if self.orientation == 'h':
# line.set_xdata([val] * 2)
# else:
# line.set_ydata([val] * 2)
def
anim_func
(
self
,
i
):
print
(
'anim_func:'
,
i
)
plt
.
xkcd
(
scale
=
1
,
length
=
100
,
randomness
=
2
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录