立即学习:https://edu.youkuaiyun.com/course/play/24797/282218?utm_source=blogtoedu
import pygal #2020年2月 carData = {'哈弗H6': 4033, '长安CS75': 3668, '途观': 3456, '博越': 3117, '奔驰GLC': 3093, '捷途X700': 3007, '探岳': 2976, '观致5': 2083, '途岳': 2006, '瑞虎8': 1988} #2019年2月 carData2 = {'哈弗H6': 24537, '长安CS75': 10487, '途观': 12708, '博越': 10804, '奔驰GLC': 7788, '捷途X700': 7096, '探岳': 4849, '观致5': 3036, '途岳': 4817, '瑞虎8': 4294} # dm = pygal.Pie() # for d in carData.keys(): # dm.add(d, carData[d]) # dm.title = '2020年2月SUV销量TOP10' # dm.legend_at_bottom = True # # #空心饼图图 # dm.inner_radius=0.5 # #半圆的饼图 # dm.half_pie=True # dm.render_to_file('test64.svg') dm = pygal.Dot() dm.title='SUV—2月销量对比' dm.add('2020年2月SUV销量数量',carData.values()) dm.add('2019年2月SUV销量数量',carData2.values()) dm.x_labels = carData.keys() dm.x_title='SUV名称' dm.y_label_rotation=45 # dm.y_title='销售数量' dm.legend_at_bottom=True #Y轴的虚线 dm.show_y_guides=True #X轴的虚线 dm.show_x_guides=True dm.render_to_file('test64_2.svg')