3月 012021
""" https://matplotlib.org/stable/index.html Matplotlib: Visualization with Python Matplotlib is a comprehensive library for creating static, animated, and interactive visualizations in Python. """ # 导入模块并指定别名 import matplotlib.pyplot as plt # 提供输入值,解决x坐标从0开始的问题 input_values = [1, 2, 3, 4, 5] # 定义平方数列表 square = [1, 4, 9, 16, 25] # 将列表传递给函数 # plt.plot(square) # 改善图形可读性,线条加粗 # plt.plot(square, linewidth=5) # 同时提供输入值列表和输出值列表 plt.plot(input_values, square, linewidth=5) # 函数title()指定图表标题,参数fontsize指定文字大小 plt.title("Square Numbers", fontsize=24) # 函数xlable()和ylable()为每条轴设置标题并指定文字大小 plt.xlabel("Value", fontsize=14) plt.ylabel("Square of Value", fontsize=14) # 函数tick_parms()设置刻度样式,并将设置刻度文字大小 # axis n. 轴(旋转物体假想的中心线); (尤指图表中的)固定参考轴线,坐标轴; 对称中心线(将物体平分为二); plt.tick_params(axis='both', labelsize=14) # 调用matplotlib查看器,显示绘制的图形 plt.show()