Python手动定义matplotlib xlim()

2024-09-28 22:26:31 发布

您现在位置:Python中文网/ 问答频道 /正文

我想在xlim([])中放置一个单词数组来代替一系列数字。使用普通python和matplotlib。你知道吗

像这样:

ax.set_xlim(['week1', 'week2', 'week3', 'week4', 'week5', 'week6', 'week7', 'week8', 'week9', 'week10'])

实现这一目标的最佳方法是什么?你知道吗


Tags: matplotlib数字数组ax单词setxlimweek2
1条回答
网友
1楼 · 发布于 2024-09-28 22:26:31

你想要matplotlib.pyplot.xticks。比如:

# set the locations and labels of the xticks
plt.xticks( arange(10), ('week1', 'week2', 'week3', 'week4', 'week5', 'week6', 'week7', 'week8', 'week9', 'week10') )

其中,您需要的不是arange(10),而是数据的x值数组。你知道吗

相关问题 更多 >