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()