用pygal画折线图日期横坐标显示...

用pygal画折线图日期横坐标显示...无法正常显示日期,代码如下
import json
import pygal

filename = 'btc_close_2017_urllib.json'
with open(filename) as f:
btc_data = json.load(f)

dates = []
months = []
weeks = []
weekdays = []
close = []
for btc_dict in btc_data:
#current_date = datetime.strptime(btc_dict['date'],'%Y-%m-%d')
dates.append(btc_dict['date'])
months.append(int(btc_dict['month']))
weeks.append(int(btc_dict['week']))
weekdays.append(btc_dict['weekday'])
close.append(int(float(btc_dict['close'])))

line_chart = pygal.Line(show_minor_x_labels=False)
line_chart.title = '收盘价(¥)'
line_chart.x_labels = dates

line_chart.x_labels_major = dates[::20]
line_chart.add('收盘价',close)
line_chart.render_to_file('收盘价折线图(¥).svg')
结果见图,是啥原因呢?求大佬解答。
图片说明

1个回答

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问