# 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
response_dict = r.json() print(response_dict.keys()) print("total repositories: ",response_dict['total_count']) #研究有关仓库的信息 repo_dicts = response_dict['items'] names,stars = [],[] for repo_dict in repo_dicts: names.append(repo_dict['name']) stars.append(repo_dict['stargazers_count']) #可视化 my_style = LS("#333366",base_style=LCS) #让标签绕着x轴旋转45度,并隐藏了图例 chart = pygal.Bar(style=my_style,x_label_rotation=90,show_legend=False) chart.title='most stared python projects on github' chart.x_labels = names chart.add('python',stars) chart.render_to_file('python_repos.svg') # print("repositories returned: " ,len(repo_dicts)) # #研究第一个仓库 # repo_dict = repo_dicts[0] # print(repo_dict) # print("\nkeys: ",len(repo_dict))
# 研究第一个仓库 repo_dict = repo_dicts[0] print('\nKeys: ', len(repo_dict)) for key in repo_dict.keys(): print(key) # 3. 使用 Pygal 可视化仓库 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) ''' # 使用Bar() 创建一个简单的条形图,并向它传递了my_style (见❹)。我们还传递了另外两个样式实参: # 让标签绕x 轴旋转45度 (x_label_rotation=45 ),并隐藏了图例(show_legend=False ), # 因为我们只在图表中绘制一个数据系列。 ''' 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_repos.svg') # 4. 改进 Pygal 图表
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('#e6e600', 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 = 'Python' chart.x_labels = names
response_dict = r.json() print("Total repositories: ", response_dict["total_count"]) # just return part of repositories repo_dicts = response_dict["items"] names, plot_dicts = [], [] for repo_dict in repo_dicts: name = repo_dict["name"] names.append(name) plot_dicts.append({ "value": repo_dict["stargazers_count"], "label": repo_dict["description"], "xlink": repo_dict["html_url"], }) my_style = LS("#336699", 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 = 18 # limit length of label 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"
import pygal from pygal.style import LightColorizedStyle as LCS, LightenStyle as LS my_style = LS('#341256', base_style = LCS) chart = pygal.Bar(style = my_style, x_label_rotation = 0, show_legend = False) chart.title = 'PYTHON-PROJECTS' chart.x_labels = ['awesome-python', 'public-apis', 'youtube-dl'] plot_dicts = [ {'value':51431, 'label':'DESCRIPTION OF AWESOME-PYTHON'}, {'value':37959, 'label':'DESCRIPTION OF PUBLIC-APIS'}, {'value':37789, 'label':'DESCRIPTION OF YOUTUBE-DL'}, ] chart.add('', plot_dicts) chart.render_to_file('bar_descriptions.svg')
response_dict = req.json() localtime = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time())) print("Now the time is: ", localtime) # 打印当前时间 print("There's Total repositories on GitHub: ", response_dict['total_count']) # 统计当前 Github 上的 python repositories 总数量 repo_dicts = response_dict['items'] names, stars = [], [] for repo_dict in repo_dicts: names.append(repo_dict['name']) stars.append(repo_dict['stargazers_count']) # 可视化环境 # my_style = LS('#333366', base_style=LCS) my_style = LS(base_style=LCS) # my_config = pygal.Config() # 创建一个 pygal的 Config类的实例; # my_config.x_label_rotation = 45 # my_config.show_legend = False # my_config.title_font_size = 28 # my_config.label_font_size = 18 # 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 = pygal.Bar(style=my_style, x_label_rotation=45, show_legend=False) chart.title = 'GitHub 上最受欢迎的 Python 项目' chart.x_labels = ['httpie', 'django', 'flask']
) # 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
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
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 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(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
} 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'
# 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
#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
#探索有关仓库的信息 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
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')
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')
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('#cc0000', 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 = 'Scala' 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)
import pygal from pygal.style import LightColorizedStyle as LCS, LightenStyle as LS meu_estilo = LS('#333366', base_style=LCS) chart = pygal.Bar(style=meu_estilo, x_label_rotation=50, show_legend='Legendas') chart.title = 'Projetos Python' 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('Pagina_543.svg') """ O Pygal usa o número associado a 'value' para descobrir a altura que cada barra deve ter, e utiliza a string associada a 'label' para criar a dica de contexto de cada barra. Por exemplo, o primeiro dicionário em v criará uma barra que representa um projeto com 16.101 estrelas, e sua dica de contexto conterá Description of httpie (Descrição de httpie). O método add() precisa de uma string e de uma lista. """
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("total_count", repo_dicts['total_count']) # 研究有关仓库的信息 repo_dict = repo_dicts['items'] # 获取names starts names, repo_stars = [], [] for repo in repo_dict: names.append(repo['name']) plot_dict = { 'value': repo['stargazers_count'], 'label': str(repo['description']), 'xlink': repo['html_url'] } repo_stars.append(plot_dict) my_style = LS('#58dada', 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 # 设置x轴上名称最多15字+省略号 my_config.truncate_label = 15 # 隐藏图表中的水平线 my_config.show_y_guides = False my_config.width = 1000
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
#探索有关仓库的信息 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('#EF255F', 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 Java 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' }, ]
#对每一篇文章都执行一个API调用 url = 'https://hacker-news.firebaseio.com/v0/item/' + str( submisssion_id) + '.json' submisssion_r = requests.get(url) # print("Status Code: ",submisssion_r.status_code) response_dict = submisssion_r.json() submisssion_dict = { 'label': response_dict['title'], 'xlink': response_dict['url'], # 'link': "http://news.ycombinator.com/item?id="+str(submisssion_id)+"", 'value': response_dict.get('descendants', 0), #指定的键存在时返回相应的值,不存在时返回0 } names.append(submisssion_dict['label']) submisssion_dicts.append(submisssion_dict) submisssion_dicts = sorted(submisssion_dicts, key=itemgetter('value'), reverse=True) my_comfig = pygal.Config() my_comfig.title = 'Top 10 Stories From Hacker-News' my_comfig.x_label_rotation = 45 my_comfig.width = 1000 my_style = LS('#883333', base_style=LCS) chart = pygal.Bar(my_comfig, style=my_style) chart.x_labels = names chart.add('stories', submisssion_dicts) chart.render_to_file('Top stories.svg')
#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')
# # info_list['name'] = repo_dict['name'] # # info_list['owner'] = repo_dict['owner']['login'] # # info_list['stars'] = repo_dict['stargazers_count'] # info_list['repository'] = repo_dict['html_url'] # # info_list['created'] = repo_dict['created_at'] # # info_list['updated'] = repo_dict['updated_at'] # info_list['description'] = repo_dict['description'] # info_lists.append(info_list) # # 将数据写入JSON文件 # filename = './web_api/python_repos.json' # with open(filename, 'w', encoding='utf-8') as f: # json.dump(info_lists, f, ensure_ascii=False) # 可视化 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 # y_ls = [] # for y_l in range(0, 55001, 5000): # y_ls.append(y_l) # my_config.y_labels = y_ls my_config.truncate_label = 15 my_config.show_y_guides = True my_config.width = 1000
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'