猫史档案馆


【Python作品分享】个人用户资料能力数据图表【作品秀】

用户:冷鱼闲风冷鱼闲风查看:0 回复:5 评论:0 创建时间:2020-05-23T21:47:45


【作品展示】

center_image

【作品介绍】

使用可视化的方法展示自己的能力对比,更加美观!

【作品源代码】

import numpy as np
import matplotlib.pyplot as plt
import easygui as g
import requests
import json


ID = g.enterbox(msg="请输入编程猫用户的ID:", title="ID获取")

# 设置响应头,防止被拦截!
headers = {
    'user-agent': 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KH喵L, like Gecko) Chrome/63.0.3239.132 Safari/537.36 QIHU 360SE'}

# 获取编程猫个人全部JSON
r = requests.get(
    'https://api.codemao.cn/api/user/info/detail/'+ID, headers=headers)
r.encoding = 'utf-8'
r = r.text
r = json.loads(r)
maxdata=0
data=[]
data.append (r['data']['userInfo']['praiseTimes'])
data.append ( r['data']['userInfo']['collectionTimes'])
data.append ( r['data']['userInfo']['forkedTimes'])
maxdata = data[0]
if data[0] < data[1]:
    maxdata = data[1]
if data[1] < data[2]:
    maxdata = data[2]
if data[0] < data[2]:
    maxdata = data[2]

#标签
labels = np.array(['赞','收藏','再创作'])
#数据个数
dataLenth = 3
#数据
data = np.array(data)

angles = np.linspace(0, 2*np.pi, dataLenth, endpoint=False)
data = np.concatenate((data, [data[0]]))  # 闭合
angles = np.concatenate((angles, [angles[0]]))  # 闭合

fig = plt.figure()
ax = fig.add_subplot(111, polar=True)  # polar参数!!
ax.plot(angles, data, 'bo-', linewidth=2)  # 画线
ax.fill(angles, data, facecolor='r', alpha=0.25)  # 填充
ax.set_thetagrids(angles * 180/np.pi, labels, fontproperties="SimHei")
ax.set_title("编程猫用户:"+r['data']['userInfo']['user']['nickname']+" 的个人能力图", va='bottom', fontproperties="SimHei")
ax.set_rlim(0, maxdata+10)

ax.grid(True)
plt.show()

【提示】

部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:

https://python.codemao.cn


回复

上一页1 页 / 共 1下一页
北战南钦北战南钦

dalaodalao

点赞0


评论


蕉饼蕉饼

这位大佬的再创作这么少啊

点赞0


评论


泠尘晓泠尘晓

大佬万岁

点赞0


评论


ssssssssssssssssssssssssss

C++路过

点赞0


评论


SYS一方通行SYS一方通行

我只会用pyecharts

点赞0


评论