如何使字符串到目前为止并在图表上显示

时间:2018-03-01 03:37:33

标签: python-3.x matplotlib

import datetime    
a = '20180204'
a_time = datetime.datetime.strptime(a,'%Y%m%d')

结果是

datetime.datetime(2018, 2, 4, 0, 0)

print(a_time)

2018-02-04 00:00:00

我希望它只是像'208-02-04'那样显示出来。我可以使用哪个命令?

我用matplotlib显示它

x_list = list()
y_list = list()
for i in range(0,len(stock_order)): # stock_order is a list of tuple
    x = stock_order[i][0]
    xt = datetime.datetime.strptime(x,'%Y%m%d')
    x_list.append(x)
    y = stock_order[i][1]
    y_list.append(y)
plt.plot(x_list,y_list)
plt.show()

enter image description here

如何让X轴显示清晰美观?

0 个答案:

没有答案