Skip to content

Commit fb15ce7

Browse files
author
littleminer
committed
[refactor] use string variable instead of hard code to set plot property
1 parent 66d4fcc commit fb15ce7

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

money_supply.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,27 @@
44
import numpy
55
import pandas
66

7+
x_label = 'Time(s)'
8+
y_label = 'M2'
9+
plot_title = 'Money Supply Unit:100 Million Yuan'
10+
ms_png_name = 'money_supply.png'
11+
712
time_money = pandas.read_csv('money_supply.csv')
813

914
t = time_money.T.values[0]
1015
m = time_money.T.values[1]
1116
x = numpy.arange(1, len(t) + 1)
1217

13-
pyplot.plot(x, m)
18+
pyplot.plot(x, m, 'ro-')
1419

15-
pyplot.xlabel('Time(s)')
20+
pyplot.xlabel(x_label)
1621
pyplot.xticks(x, t.tolist(), rotation=45)
1722

18-
pyplot.ylabel('M2')
23+
pyplot.ylabel(y_label)
1924

20-
pyplot.title('Money Supply Unit:100 Million Yuan')
25+
pyplot.title(plot_title)
2126

2227
pyplot.grid(True)
2328

24-
pyplot.savefig("Money_Supply.png")
29+
pyplot.savefig(ms_png_name)
2530
pyplot.show()

0 commit comments

Comments
 (0)