Skip to content

Commit 24fb06d

Browse files
authoredDec 15, 2018
Update arrest_chart.py
Fix Chart
1 parent dd8a860 commit 24fb06d

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed
 

‎Python3/arrest_chart.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ def chart(df_1, df_2, df_3, df_4):
5454
# creat_bar_chart_style
5555
amount_chart = pygal.Bar() # creat_chart
5656
amount_chart.x_labels = map(str, range(2001, 2018))
57+
amount_chart.x_title = 'Year'
58+
amount_chart.y_title = 'Amount'
5759
# format_data
5860
arrest_list = []
5961
fail_list = []
@@ -62,9 +64,7 @@ def chart(df_1, df_2, df_3, df_4):
6264
fail_list.append({'value': num_list[i][1], 'label': '{:.2f}%'.format(100*num_list[i][1]/data_year[i])})
6365
amount_chart.add('Arrest', arrest_list)
6466
amount_chart.add('Fail', fail_list)
65-
amount_chart.legend_at_bottom = True
66-
# render_to_arrest.svg
67-
amount_chart.render_to_file('arrest_chart.svg')
67+
6868
# creat_every_yrs_arrest.svg
6969
arrest, fail = 0, 0
7070
for i in num_list:
@@ -73,5 +73,8 @@ def chart(df_1, df_2, df_3, df_4):
7373
chart = pygal.Pie()
7474
chart.add('Arrest', [{'value': arrest, 'label': '{:.2f}%'.format(100*arrest/sum(data_year))}])
7575
chart.add('Fail', [{'value': fail, 'label': '{:.2f}%'.format(100*fail/sum(data_year))}])
76+
77+
# render_to_arrest.svg
78+
amount_chart.render_to_file('arrest_chart.svg')
7679
chart.render_to_file('every_yrs_arrest.svg')
7780
main()

0 commit comments

Comments
 (0)