# incoding=gbk import matplotlib.pyplot as plt input_values = [1, 2, 3, 4, 5] squares = [1, 4, 9, 16, 25] """ 函数plot()绘制简单的折线图 如果不给plot()提供输入值,它假设第一个数据点对应的x坐标值为0, 参数linewidth决定了plot()绘制的线条的粗细。 """ plt.plot(input_values, squares, linewidth=3) """ 函数title()给图表指定标题。参数fontsize指定了图表中文字的大小。 函数xlabel()和ylabel()为每条轴设置标题; 函数tick_params()设置刻度的样式,其中指定的实参将影响x轴和y轴上的刻度 (axes='both'),并将刻度标记的字号设置为14(labelsize=14)。 """ # 设置图表标题,并给坐标轴加上标签 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()打开matplotlib查看器,并显示绘制的图形。查看器让你能够缩放和导航图形, 单击磁盘图标可将图形保存起来。 """ plt.show()
使用函数plot()绘制简单的折线图
猜你喜欢
转载自www.cnblogs.com/merryconei123/p/13392117.html
今日推荐
周排行