1. 程式人生 > >視覺化分析存入mongodb騰訊招聘資訊

視覺化分析存入mongodb騰訊招聘資訊

TencentVisualization.py

import pymongo
import matplotlib.pyplot as plt
import pylab

# 讓matplotlib顯示中文
pylab.mpl.rcParams['font.sans-serif'] = ['SimHei']
# 連線mongodb
client = pymongo.MongoClient(host="localhost", port=27017)
db = client.py3
collection = db.tencent
# 獲取資訊條數
technology = collection.count({"job_category": "技術類"})
design = collection.count({"job_category": "設計類"})
product = collection.count({"job_category": "產品/專案類"})
market = collection.count({"job_category": "市場類"})
function = collection.count({"job_category": "職能類"})
edit = collection.count({"job_category": "內容編輯類"})
service = collection.count({"job_category": "客戶服務類"})
# 數值
values = [technology, design, product, market, function, edit, service]
# 標籤
labels = ["技術類", "設計類", "產品/專案類", "市場類", "職能類", "內容編輯類", "客戶服務類"]
# 突出部分
explode = [0, 0, 0, 0, 0, 0.2, 0.5]
# 顏色
colors = ["yellow", "blue", "red", "purple", "green", "brown", "black"]
# 標題
plt.title("招聘崗位型別比例", fontsize=25, color="red")
# 標題
plt.pie(values, labels=labels, colors=colors, autopct="%1.2f%%", explode=explode)
plt.axis("equal")
plt.show()