数据可视化、线性代数与统计基础入门
1. 数据可视化
1.1 散点图绘制
首先来看一个关于考试成绩的例子,我们有两组考试成绩数据,通过 Python 的 matplotlib 库来绘制散点图。以下是具体代码:
import matplotlib.pyplot as plt
test_1_grades = [ 99, 90, 85, 97, 80]
test_2_grades = [100, 85, 60, 90, 70]
plt.scatter(test_1_grades, test_2_grades)
plt.title("Axes Aren't Comparable")
plt.xlabel("test 1 grade")
plt.ylabel("test 2 grade")
plt.show()
这段代码的执行流程如下:
1. 导入 matplotlib.pyplot 库,用于绘图。
2. 定义两组考试成绩数据 test_1_grades 和 test_2_grades 。
3. 使用 plt.scatter 函数绘制散点图,将两组成绩数据作为参数传入。
4. 使用 plt.title 、 plt.xlabel 和 plt.ylabel 分别设置图表标题、x 轴标签和 y 轴标签。
5. 最后使用
超级会员免费看
订阅专栏 解锁全文

1万+

被折叠的 条评论
为什么被折叠?



