上传文件至 /
This commit is contained in:
42
huatu.py
Normal file
42
huatu.py
Normal file
@@ -0,0 +1,42 @@
|
||||
#终端要安装pip install matplotlib还有conda install tk
|
||||
import json
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
|
||||
#柱状图
|
||||
#x = ["张三", "李四", "王五", "赵六", "钱七", "孙八", "周九", "吴十", "郑明", "王芳"]
|
||||
#y = [92, 88, 76, 85, 90, 82, 78, 95, 72, 88]
|
||||
|
||||
#plt.bar(x,y)
|
||||
#plt.title('title')
|
||||
#plt.show()
|
||||
|
||||
|
||||
#折线图
|
||||
with open("viz_data.json", "r", encoding="utf-8") as f:
|
||||
data = json.load(f)
|
||||
|
||||
#line = data['line_chart']
|
||||
#print(line)
|
||||
#month = line['month']
|
||||
|
||||
#plt.plot(month, line['语文'])
|
||||
#plt.plot(month, line['数学'])
|
||||
#plt.show()
|
||||
|
||||
|
||||
# 饼图绘制代码
|
||||
#pie = data['pie_chart']
|
||||
#print(pie)
|
||||
|
||||
#plt.pie(pie['values'])
|
||||
#plt.show()
|
||||
|
||||
|
||||
# 散点图绘制
|
||||
sc = data['scatter_chart']
|
||||
x_sc = sc['x']
|
||||
y_sc = sc['y']
|
||||
|
||||
plt.scatter(x_sc,y_sc)
|
||||
plt.show()
|
||||
Reference in New Issue
Block a user