SVG:此XML文件似乎没有任何与之关联的样式信息

时间:2017-06-20 08:00:18

标签: python svg

我正在尝试从GitHub获取一些项目数据并将其可视化,但我的程序似乎有一个错误。当我打开SVG文件时,我得到:This XML file does not appear to have any style information associated with it。文档树如下所示。这个程序有问题吗?谢谢。

import requests
import pygal
from pygal.style import LightColorizedStyle as Lcs,  LightenStyle as Ls

URL = 'https://api.github.com/search/repositories?q=language:python&sort=stars'
r = requests.get(URL)
print("Status code:", r.status_code)

response_dict = r.json()
print("Total repositories:", response_dict['total_count'])
repo_dicts = response_dict['items']
names, plot_dicts = [], []
for repo_dict in repo_dicts:
    names.append(repo_dict['name'])

    plot_dict = {
        'value': repo_dict['stargazers_count'],
        'label': repo_dict['description'],
    }
    plot_dicts.append(plot_dict)
my_style = Ls('#333666', base_style=Lcs)
chart = pygal.Bar(style=my_style, x_label_rotation=45, show_legend=False)
chart.title = 'Most-Starred Python Projects on GitHub'
chart.x_labels = names

chart.add('', plot_dicts)
chart.render_to_file('python_repos.svg')

0 个答案:

没有答案