在使用 Python 绘图时,可以使用 matplotlib 库中的函数来设置 x 轴的文本标签。具体来说,可以使用 matplotlib.pyplot 模块中的 xticks() 函数来设置 x 轴的标签。
例如,如果你想在 x 轴上显示文本标签 "apple", "banana", "orange" 和 "mango",可以使用如下代码:
import matplotlib.pyplot as plt
x = [1, 2, 3, 4]
y = [5, 6, 7, 8]
plt.plot(x, y)
plt.xticks([1, 2, 3, 4], ["apple"