From 07c28c73317c1d81582eb8d2e6baab84bf639f95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BD=97=E8=89=BA=E6=AC=A3?= <2509165020@student.example.com> Date: Thu, 18 Jun 2026 16:22:42 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=96=87=E4=BB=B6=E8=87=B3?= =?UTF-8?q?=20/?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- huatu.py | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 huatu.py diff --git a/huatu.py b/huatu.py new file mode 100644 index 0000000..849743d --- /dev/null +++ b/huatu.py @@ -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() \ No newline at end of file