mpl_squares.py 523 字节
Newer Older
逆流者blog's avatar
逆流者blog 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
import matplotlib.pyplot as plt

input_value = [1, 2, 3, 4, 5]
squares = [1, 4, 9, 16, 25]
# 绘制图形,linewidth是线条粗细
plt.plot(input_value, squares, linewidth=5)

# 设置图标标题,并给坐标轴加上标签 这个标题给中文报错了,暂时不明白
plt.title("Square Numbers", fontsize=24)
plt.xlabel('Value', fontsize=14)
plt.ylabel('Square of Value', fontsize=14)

# 设置刻度标记的大小(就是样式)
plt.tick_params(axis='both', labelsize=14)

# 打开matplotlib查看器
plt.show()