3 月 022021
 
"""
使用scatter()绘制一系列点
"""
import matplotlib.pyplot as plt

# 向scatter()传递两个分别包含x值和y值的列表
x_values = [1, 2, 3, 4, 5]
y_values = [1, 4, 9, 16, 25]

# 列表传递给scatter()时,依次从每个列表中读取一个值来绘制一个点
plt.scatter(x_values, y_values, s=100)

# 设置图表标题并给坐标轴加上标签
plt.title("Square Numbers", fontsize=24)
plt.xlabel("Value", fontsize=14)
plt.ylabel("Square of Value", fontsize=14)

plt.tick_params(axis='both', which='major', labelsize=14)

plt.show()
3 月 022021
 
"""
使用scatter()绘制散点图
"""
import matplotlib.pyplot as plt

# 绘制单个点,使用scatter()函数并传递一对x和y坐标
# plt.scatter(2, 4)
# 设置坐标并指定点的尺寸
plt.scatter(2, 4, s=200)

# 设置图表标题并给坐标轴加上标签
plt.title("Square Numbers", fontsize=24)
plt.xlabel("Value", fontsize=14)
plt.ylabel("Square of Value", fontsize=14)

# 设置刻度标记的大小
plt.tick_params(axis='both', which='major', labelsize=14)

plt.show()