在Python中,使用matplotlib库画图时,设置纵坐标可以通过`plt.ylabel`函数来实现。下面是一个简单的示例代码,展示了如何使用matplotlib绘制折线图并设置纵坐标标签:
import matplotlib.pyplot as plt定义数据x_values = [1, 2, 3, 4, 5]y_values = [1, 4, 9, 16, 25]绘制折线图plt.plot(x_values, y_values)设置纵坐标标签plt.ylabel('纵坐标标签')显示图形plt.show()
在这个例子中,`plt.ylabel`函数用于设置纵坐标的标签为“纵坐标标签”。你可以根据需要更改这个标签的文本。

