'value': repo_dict['stargazers_count'], 'label': description, 'xlink': repo_dict['html_url'] } plot_dicts.append(plot_dict) else: break #=========Configuration============== my_config = pygal.Config() my_config.x_label_rotation = 45 my_config.show_legend = False # my_config.show_y_guides=False my_config.width = 1000 #==================================== my_style = LS('#333366', base_style=LCS, title_font_size=24, label_font_size=14, major_label_font_size=18, truncate_label=15) chart = pygal.Bar(my_config, style=my_style) chart.title = "Most Stared Python Projects on Github" chart.x_labels = names chart.y_title = 'The number of stars' chart.add('', plot_dicts) if __name__ == '__main__': app.run_server(debug=True)
#print("Number of items:", len(repo_dicts)) names, stars = [], [] for repo_dict in repo_dicts: names.append(repo_dict['name']) stars.append(repo_dict['stargazers_count']) #plot_dict = { # 'value': repo_dict['stargazers_count'], # 'label': repo_dict['description'], # } # plot_dicts.append(plot_dict) # Erstellt die Visualisierung. my_style = LS('#334466', base_style=LCS) my_config = pygal.Config() my_config.x_label_rotation = 45 my_config.show_legend = False my_config.title_font_size = 24 my_config.label_font_size = 14 my_config.major_label_font_size = 18 my_config.truncate_label = 15 my_config.show_y_guides = False my_config.width = 1000 chart = pygal.Bar(my_config, style=my_style) chart.title = 'Meist angeSTARte Projekte auf GitHub' chart.x_labels = names
import pygal from pygal.style import LightColorizedStyle as LCS, LightenStyle as LS my_style = LS('#333366', base_style=LCS) chart = pygal.Bar(style=my_style, x_label_rotation=45, show_legend=False) chart.title = 'Python Projects' chart.x_labels = ['httpie', 'django', 'flask'] plot_dicts = [ {'value': 16101, 'label': 'Description of httpie.'}, {'value': 15028, 'label': 'Description of django.'}, {'value': 14798, 'label': 'Description of flask.'}, ] chart.add('', plot_dicts) chart.render_to_file(r'images\bar_descriptions.svg')
repo_dicts = dates['items'] names = [] repo_infos = [] for repo_dict in repo_dicts: names.append(repo_dict['name']) repo_info = { 'value': repo_dict['stargazers_count'], 'label': repo_dict['description'], #这里没有用str(),程序没有报错 'xlink': repo_dict['html_url'], } repo_infos.append(repo_info) #可视化 my_style = LS('#994433', base_style=LCS) my_config = pygal.Config() my_config.x_label_rotation = 40 my_config.show_legend = False my_config.show_y_guides = False my_config.truncate_label = 13 my_config.title_font_size = 26 my_config.label_font_size = 15 my_config.major_label_font_size = 15 my_config.width = 1000 chart = pygal.Bar(my_config, style=my_style) chart._title = 'Most_Starred Java Projects on Github' chart.x_labels = names
#print("Repositories returned:", len(repo_dicts)) #repo_dict = repo_dicts[0] #print('\nKeys:', len(repo_dict)) #for key in sorted(repo_dict.keys()): # print(key) names = [] stars = [] plot_dicts = [] for repo_dict in repo_dicts: names.append(repo_dict['name']) stars.append({ 'value': int(repo_dict['stargazers_count']), 'label': str(repo_dict['description']), # 根据label 显示 鼠标悬停 的显示 'xlink': str(repo_dict['html_url']) }) # 根据 xlink ,处理 鼠标点击条目 # x_label_rotation =45 x轴上的标签 旋转45度 # show_legend=False 隐藏图例 pygal_bar = pygal.Bar(style=LS('#336699', base_style=LCS), x_label_rotation=45, show_legend=False) pygal_bar.title = 'Most-Starred Python Projects on GitHub' pygal_bar.x_labels = names pygal_bar.add('', stars) pygal_bar.render_to_file('python_repos.svg')
#探索有关仓库的信息 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': str(repo_dict['description']), 'xlink': repo_dict['html_url'], #这个功能真是棒棒哒 } plot_dicts.append(plot_dict) #可视化 my_style = LS('#40A798', base_style=LCS) my_config = pygal.Config() my_config.x_label_rotation = 45 my_config.show_legend = False my_config.title_font_size = 24 my_config.label_font_size = 14 my_config.major_label_font_size = 18 my_config.truncate_label = 15 my_config.show_y_guides = False my_config.width = 1000 chart = pygal.Bar(my_config, style=my_style) #通过my_config传递了所以配置 chart.title = 'Most-Starrred Python Projects on Github' chart.x_labels = names
'label':repo_dict['description'], 'xlink':repo_dict['html_url'] } plot_dicts.append(plot_dict) else: plot_dict={'value':repo_dict['stargazers_count'], 'label':'ABC', 'xlink':repo_dict['html_url']} plot_dicts.append(plot_dict) print(len(names)) print() print(len(plot_dicts)) print() my_style = LS('#993366', base_style=LCS) my_config = pygal.Config() my_config.x_label_rotation = 30 my_config.show_legend = True my_config.title_font_size = 24 my_config.label_font_size = 14 my_config.major_label_font_size = 18 my_config.truncate_label = 15 my_config.show_y_guides = False chart = pygal.Bar(my_config, style=my_style) chart.title = 'Python Projects' chart.x_labels = names chart.add('Star', plot_dicts)
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'], 'xlink': repo_dict['html_url'], } if plot_dict['label'] == None: plot_dict['label'] = '' plot_dicts.append(plot_dict) # make visualisation my_style = LS('#333366', base_style=LCS, tooltip_font_size=10) # set config for bar chart cfg = pygal.Config() cfg.x_label_rotation = 45 cfg.show_legend = False cfg.title_font_size = 24 cfg.label_font_size = 14 cfg.major_label_font_size = 18 cfg.truncate_label = 15 cfg.show_y_guides = False cfg.width = 1000 cfg.height = 450 chart = pygal.Bar(cfg, style=my_style) chart.title = 'Most-starred python repos on GitHub'
# Explore information about the repositories. 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'], 'xlink': repo_dict['html_url'], } plot_dicts.append(plot_dict) # Make visualization. my_style = LS('#333399', base_style=LCS) my_config = pygal.Config() my_config.x_label_rotation = 45 my_config.show_legend = False my_config.title_font_size = 24 my_config.label_font_size = 14 my_config.major_label_font_size = 18 my_config.truncate_label = 15 my_config.show_y_guides = False my_config.width = 1000 chart = pygal.Bar(my_config, style=my_style) chart.force_uri_protocol = 'http' chart.title = 'Most-Starred Python Projects on GitHub' chart.x_labels = names
import pygal from pygal.style import LightColorizedStyle as LCS, LightenStyle as LS my_style = LS('#566111', base_style=LCS) chart = pygal.Bar(style=my_style, x_label_rotation=45, show_legend=False) chart.title = 'Python Projects' chart.x_labels = ['httpie', 'django', 'flask'] plot_dicts = [ { 'value': 16101, 'label': 'Description of httpie.' }, { 'value': 15028, 'label': 'Description of django.' }, { 'value': 14798, 'label': 'Description of flask.' }, ] chart.add('', plot_dicts) chart.render_to_file('bar_description.svg')
# if repo_dict['description'] == None : # print(repo_dict['name']) plot_dicts.append(plot_dict) ###====>>上版错误plot--repo #可视化 #my_style = LS('#333366',base_style=LCS) ##图标样式配置 my_config = pygal.Config() ##Config()-class实例 my_config.x_label_rotation = 45 ##x标签旋转45° my_config.show_legend = False ##是否显示图例 my_config.truncate_label = 15 ##截断标签字符数 my_config.show_y_guides = False ##是否显示y轴参考线 my_config.width = 1000 ######pygal 2.0.0变动Move font_size config to style. my_config.style = LS('#333366',base_style=LCS) my_config.style.title_font_size = 24 ##图标标题字号 my_config.style.label_font_size = 14 ##副标签字号 my_config.style.major_label_font_size = 18 ##主标签字号 ########################################################### #chart = pygal.Bar(style=my_style,x_label_rotation=45,show_legend=False) chart = pygal.Bar(my_config) chart.title = 'Most-Starred Python Projects on Github' chart.x_labels = names #chart.add('',stars) chart.add('',plot_dicts) chart.render_to_file('python_repos01.svg')
for repo_dict in repo_dicts : repo_name.append(repo_dict['name']) # repo_stars.append(repo_dict['stargazers_count']) repo_plot_dict = { 'value': repo_dict['stargazers_count'], 'label': str(repo_dict['description']), 'xlink': repo_dict['html_url'], } repo_plot_dicts.append(repo_plot_dict) import pygal from pygal.style import LightColorizedStyle as LCS, LightenStyle as LS #make visualisation my_style = LS('#337365', base_style=LCS) #creating a configuration object that contains all of our customizations to pass to Bar(): my_config = pygal.Config() my_config.x_label_rotation = 45 my_config.show_legend = False my_config.title_font_size = 24 my_config.label_font_size = 14 my_config.major_label_font_size = 18 my_config.truncate_label = 15 my_config.show_y_guides = False my_config.width = 1000 hist = pygal.Bar(my_config, style=my_style) hist.title = "GitHub's Popular Python Repos;26/08/18"
# 列表plot_dicts存放star数和工具提示 names, plot_dicts = [], [] for repo_dict in repo_dicts: names.append(repo_dict['name']) plot_dict = { 'value': repo_dict['stargazers_count'], # star数 # 项目描述,防止有项目没有description的报错 'label': repo_dict['description'] if repo_dict['description'] else 'There is no description about this project', 'xlink': repo_dict['html_url'] # 将条形转换为相应的链接,链接到相应的github页面 } plot_dicts.append(plot_dict) # 可视化 my_style = LS('#333366', base_style=LCS) # 基色设置为深蓝 my_config = pygal.Config() my_config.x_label_rotation = 45 # 让标签绕x轴旋转45度 my_config.show_legend = False # 隐藏图例 my_config.title_font_size = 24 # 标题字体大小 my_config.label_font_size = 14 # 副标签字体大小(这里是x轴上的项目名及y轴上的大部分数字) my_config.major_label_font_size = 18 # 主标签字体大小(y轴上5000整数倍的刻度,比副标签更大方便区分) my_config.truncate_label = 15 # 将较长项目名称缩短为15个字符,用鼠标指向截短的项目名显示完整 my_config.show_y_guides = False # 隐藏水平线 my_config.width = 1000 # 自定义宽度 chart = pygal.Bar(my_config, style=my_style) chart.title = 'Most-Starred Python Projects on GitHub' chart.x_labels = names
repo_dicts = response_dict['items'] names, plot_dicts = [], [] for repo_dict in repo_dicts: names.append(repo_dict['name']) description = repo_dict['description'] if not description: description = 'No description provided.' plot_dict = { 'value': repo_dict['stargazers_count'], 'label': description, 'xlink': repo_dict['html_url'] } plot_dicts.append(plot_dict) my_style = LS('#DC143C', base_style=LCS) my_config = pygal.Config() my_config.x_label_rotation = 45 my_config.show_legend = False my_config.truncate_label = 15 my_config.title_font_size = 24 my_config.label_font_size = 14 my_config.major_label_font_size = 18 my_config.show_y_guides = False chart = pygal.Bar(my_config, style=my_style) chart.title = "Most-Starred Python Projects on GitHub" chart.x_labels = names chart.add('', plot_dicts) chart.render_to_file('java_repos.svg')
names, stars, plot_dicts = [], [], [] for repo in repo_dicts: names.append(repo['name']) stars.append(repo['stargazers_count']) description = repo['description'] if(not description): description = 'description not found' plot_dict = { 'value': repo['stargazers_count'], 'label': description, 'xlink': repo['html_url'] } plot_dicts.append(plot_dict) my_style = LS('#006600', base_style=LCS) my_style.title_font_size = 24 my_style.label_font_size = 14 my_style.major_label_font_size = 18 my_config = pygal.Config() my_config.x_label_rotation = 45 my_config.show_legend = False my_config.truncate_label = 15 my_config.show_y_guides = False my_config.width = 1000 chart = pygal.Bar(my_config, style=my_style) #chart = pygal.Bar(style=my_style, x_label_rotation=45, show_legend=False) chart.title = 'Javascript' chart.x_labels = names
# Explora informações sobre os repositórios. 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'] or '', 'xlink': repo_dict['html_url'], } plot_dicts.append(plot_dict) # Cria a visualização. my_style = LS('#3354FF', base_style=LCS) my_config = pygal.Config() my_config.x_label_rotation = 45 my_config.show_legend = False my_config.title_font_size = 24 my_config.label_font_size = 14 my_config.major_label_font_size = 18 my_config.truncate_label = 15 my_config.show_y_guides = False my_config.width = 1000 chart = pygal.Bar(my_config, style=my_style) chart.title = 'Most-Starred Perl Projects on GitHub' chart.x_labels = names
names, plot_dicts = [], [] for repo_dict in repo_dicts: names.append(repo_dict["name"]) plot_dict = { "value": repo_dict["stargazers_count"], "label": str(repo_dict["description"]), # 添加超链接 "xlink": repo_dict["html_url"] } plot_dicts.append(plot_dict) # 数据可视化 # 设置图表样式 my_style = LS("#336699", base_style=LCS) my_config = pygal.Config() # x_label_rotation=45 让标签绕x轴旋转45度 my_config.x_label_rotation = 45 # show_legend=False 不显示图例 my_config.show_legend = False my_config.title_font_size = 24 my_config.label_font_size = 14 my_config.major_label_font_size = 18 # 将较长的项目名缩短为15字符 my_config.truncate_label = 15 # 隐藏水平线 my_config.show_y_guides = False
} plot_dicts.append(plot_dict) ''' print('\nName:', repo_dict['name']) print('Owner:', repo_dict['owner']['login']) print('Stars:', repo_dict['stargazers_count']) print('Repository:', repo_dict['html_url']) print('Created:', repo_dict['created_at']) print('Updated:', repo_dict['updated_at']) print('Description:', repo_dict['description']) ''' ##Make visualization. p_style = LS('#333366', basestyle = LCS) p_style.title_font_size = 24 p_style.label_font_size = 12 p_style.major_label_font_size = 14 p_config = pygal.Config() p_config.x_label_rotation = 45 p_config.show_legend = False p_config.truncate_label = 15 #p_config.show_y_guides = False p_config.width = 1000 chart = pygal.Bar(p_config, style = p_style ) chart.title = 'Most-Starred JavaScript Project on GitHub'
reverse=True) titles, comment_dicts = [], [] for submission_dict in submission_dicts: # print('\nSubmission Title:', submission_dict['title']) # print("Discussion link:", submission_dict['link']) # print("Comments:", submission_dict['comments']) titles.append(submission_dict['title']) comment_dict = { 'value': submission_dict['comments'], 'xlink': submission_dict['link'], } comment_dicts.append(comment_dict) my_style = LS('#336633', base_style=LCS) my_config = pygal.Config() my_config.x_label_rotation = 45 my_config.show_legend = False my_config.title_font_size = 24 my_config.label_font_size = 14 my_config.major_label_font_size = 18 my_config.truncate_label = 15 my_config.show_y_guides = False my_config.width = 1000 chart_cmt = pygal.Bar(my_config, style=my_style) chart_cmt.x_labels = titles chart_cmt.add('cmts', comment_dicts) chart_cmt.render_to_file('hn_submission_visual.svg')
# print(key) names, stars = [], [] for repo in returned_repositories: name = repo['name'] names.append(name) star_count = repo['stargazers_count'] # description = repo['description'] url_link = repo['html_url'] description = 'The total stars of ' + name star = {'value': star_count, 'label': description, 'xlink': url_link} stars.append(star) chart_style = LS('#333366', base_style=LCS) chart_config = pygal.Config() chart_config.show_legend = False chart_config.title_font_size = 24 chart_config.label_font_size = 14 chart_config.major_label_font_size = 18 chart_config.truncate_label = 15 chart_config.show_y_guides = False chart_config.width = 1000 chart = pygal.Bar(chart_config, style=chart_style, x_label_rotation=45, show_legend=False) chart.title = 'Most-Starred Python Projects on GitHub' chart.x_labels = names
import requests import json import pygal from pygal.style import LightSolarizedStyle as LSL, LightenStyle as LS my_config = pygal.Config() my_config.x_label_rotation = 45 my_config.show_legend = False my_config.title_font_size = 25 my_style = LS("#240699", base_style = LSL) url = "https://api.github.com/search/repositories?q=language:bash&sort=stars" number_of_repos = 10 r = requests.get(url) status_code = r.status_code values, names = [], [] if status_code == 200: data_dict = r.json() repo_dict = data_dict['items'] # print('Status Code:', status_code) # print('results:', data_dict['total_count']) # print('') # print('Information about the first {} repositories:'.format(number_of_repos)) for index in range(number_of_repos): # print('Name:', repo_dict[index]['name']) # print('Description:', repo_dict[index]['description'])
print("Number of items:",len(repo_dicts)) names,stars,plot_dicts=[],[],[] for repo_dict in repo_dicts: names.append(repo_dict['name']) stars.append(repo_dict['stargazers_count']) plot_dict={ 'value': repo_dict['stargazers_count'], 'label': repo_dict['description'], 'xlink': repo_dict['html_url'], } plot_dicts.append(plot_dict) # 可视化 my_style=LS(base_style=LCS) my_config=pygal.Config() my_config.x_label_rotation=45 my_config.show_legend=False my_config.title_font_size=24 my_config.label_font_size=14 my_config.major_labor_font_size=18 my_config.truncate_label=15 my_config.show_y_guides=False my_config.width=1000 chart=pygal.Bar(my_config,style=my_style) chart.title='Most-Starred Python Projects on GitHub' chart.x_labels=names
# coding:utf-8 # author: Tao yong # Python ''' 可视化前三个项目,并自定义添加工具提示 ''' import pygal from pygal.style import LightColorizedStyle as LCS, LightenStyle as LS my_style = LS(color='#333366', base_style=LCS) chart = pygal.Bar(style=my_style, x_label_rotation=45, show_legend=False) chart.title = 'Python Projects' chart.x_labels = ['httpie', 'django', 'flask'] #字典内含有两个键值对,pygal根据与键’value'相关联的数字确定条形的高度 #键‘label'对应的值为自定义提示 plot_dicts = [ { 'value': 16101, 'label': 'Description of httpie' }, { 'value': 15028, 'label': 'Description of django' }, { 'value': 14798, 'label': 'Description of flask' }, ]
if len(title) > 100: title = title[:100] + '...' titles.append(title) plot_dict = { 'value': submission_dict['comments'], 'label': submission_dict['id'], 'xlink': submission_dict['link'], 'title': title } plot_dicts.append(plot_dict) # Style info: # ----------------------------------------------------------------------------- style = LS('#25bec4', base_style=DS) # style.plot_background = '#586e75' # style.background = '#586e75' style.foreground = '#586e75' # all labels, guides style.foreground_strong = '#13434f' # major labels and title # style.foreground_subtle = '#fdca32' # minor guides # style.font_family = 'Helvetica' style.title_font_family = 'Helvetica' style.label_font_family = 'Helvetica' # style.major_label_font_family = 'Helvetica' # style.value_font_family = 'Helvetica' # style.value_label_font_family = 'Helvetica' # style.tooltip_font_family = 'Helvetica' # style.legend_font_family = 'Helvetica'
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' #检查url响应是否正常 repos = requests.get(url) print('Status_code:', repos.status_code) #统计总共的仓库数 results = repos.json() print('Total_repos:', results['total_count']) #统计仓库的星级 repo_dicts = results['items'] names, stars = [], [] for repo_dict in repo_dicts: names.append(repo_dict['name']) stars.append(repo_dict['stargazers_count']) #图形显示 my_style = LS('#336699', 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('', stars) chart.render_to_file('python_repos2.svg')
import pymongo from pymongo import MongoClient import pygal import operator from pygal.style import LightColorizedStyle as LCS, LightenStyle as LS client = MongoClient('localhost', 27017) db = client['imdb'] top250 = db['top250'] output_path = "chart/" my_style = LS("#e3b038", base_style=LCS) my_config = pygal.Config() my_config.x_label_rotation = 45 my_config.show_legend = False def get_countries_statistics(): """统计TOP250各国电影数量""" # 找出所有出现过的国家 countries = top250.distinct("country") countries_dict = {} for country in countries: # 计算该国出现在TOP250的电影数量 countries_dict[country] = top250.find({"country": country}).count() sorted_dict = dict( sorted(countries_dict.items(), key=operator.itemgetter(1), reverse=True)) return sorted_dict
# print("Stars: ", repo_dict["stargazers_count"]) # print("Repository: ", repo_dict["html_url"]) # print("Description: ", repo_dict['description']) # names, stars = [], [] stars = [] 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) stars.append(repo_dict["stargazers_count"]) # Make visualization my_style = LS("#333366", base_style=LCS) my_config = pygal.Config() my_config.x_label_rotation = 45 my_config.show_legend = False my_config.title_font_size = 24 my_config.label_font_size = 14 my_config.major_label_font_size = 18 my_config.truncate_label = 15 my_config.show_y_guide = False my_config.width = 1000 chart = pygal.Bar(my_config, style=my_style) # chart = pygal.Bar(style = my_style, x_label_rotation = 45, show_legend = False) chart.title = "Most-Stared Python Projects on GitHub" chart.x_labels = names chart.add("", plot_dicts) # chart.add("", stars)
) # If we are not sure if a key exists (in this case if a story has no comments the 'descendants' key won't be present for # that particular call), we can use the dict.get method in order to check, and if it doesn't exist we can set an alternative value to return instead. } submission_dicts.append(submission_dict) submission_titles.append(submission_dict['label']) submission_dicts = sorted( submission_dicts, key=itemgetter( 'value' ), # The itemgetter function pulls the value of the key we give it from the dictionary - reverse=True ) # Then we have the sorted function sort in reverse order (largest to smallest) based on the values returned. # Making PyGal visualization. my_style = LS('#555566', base_style=LCS) my_style.title_font_size = 24 my_style.label_font_size = 14 my_style.major_label_font_size = 18 my_config = pygal.Config( ) #accessing the configuration class of pygal directly my_config.x_label_rotation = 45 my_config.show_legend = False my_config.truncate_label = 15 #truncates the names of projects on y-axis if >15 characters my_config.show_y_guides = False #hides the horizontal lines on the graph from y axis my_config.width = 1000 chart = pygal.Bar(my_config, style=my_style) chart.title = 'Current Most Active Discussions on Hacker-News' chart.x_labels = submission_titles
import pygal from pygal.style import LightColorizedStyle as LCS, LightenStyle as LS my_style = LS('#337766', base_style=LCS) chart = pygal.Bar(style=my_style, x_label_rotation=45, show_legend=False) chart.title = 'Python Projects' chart.x_labels = ['httpie', 'django', 'flask'] plot_dicts = [ { 'Value': 16101, 'label': 'Description of httpie.' }, { 'Value': 15028, 'label': 'Description of django.' }, { 'Value': 14798, 'label': 'Description of flask.' }, ] chart.add('', plot_dicts) chart.render_to_file('bar_description.svg')
print('Repositories returned:', len(repo_dicts)) #提取关于仓库名字,用星级,url和description自动生成字典,在绘图时导入,生成自定义工具提示 names, info_dicts = [], [] for repo_dict in repo_dicts: names.append(repo_dict['name']) info_dict = { 'value': repo_dict['stargazers_count'], 'label': str(repo_dict['description']), #不明白为什么要加str()????? 'xlink': repo_dict['html_url'], } info_dicts.append(info_dict) #可视化结果 my_style = LS('#449966', base_style=LCS) #创建Config类的实例my_config,并设置属性 my_config = pygal.Config() my_config.x_label_rotation = 43 my_config.show_legend = False my_config.title_font_size = 26 my_config.label_font_size = 15 my_config.major_label_font_size = 19 my_config.truncate_label = 15 my_config.show_y_guides = False my_config.width = 800 chart = pygal.Bar(my_config, style=my_style) chart.title = 'Most_Starred Python Projects on Github' chart.x_labels = names