Python手动定义matplotlib xlim()
我想在xlim([])中放置一个单词数组来代替一系列数字。使用普通python和matplotlib 像这样:Python手动定义matplotlib xlim(),python,matplotlib,Python,Matplotlib,我想在xlim([])中放置一个单词数组来代替一系列数字。使用普通python和matplotlib 像这样: ax.set_xlim(['week1', 'week2', 'week3', 'week4', 'week5', 'week6', 'week7', 'week8', 'week9', 'week10']) 实现这一点的最佳方法是什么?您需要matplotlib.pyplot.xticks。比如: # set the locations and labels of the xtic
ax.set_xlim(['week1', 'week2', 'week3', 'week4', 'week5', 'week6', 'week7', 'week8', 'week9', 'week10'])
实现这一点的最佳方法是什么?您需要
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值数组。您需要设置xtick
,而不是xlim
。看