[英]Matplotlib major locators for bar plot
假設我繪制了一個條形圖:
from matplotlib.ticker import IndexLocator
f , ax = plt.subplots(figsize=(10,5))
ax.bar(x, y, alpha=0.7, align='center')
如何調整主要定位器的位置,以使每個條形都有一個?
我嘗試了:
ax.xaxis.set_major_locator(IndexLocator(x))
但我得到:
TypeError: __init__() missing 1 required positional argument: 'offset'
不知道這是否是正確的方法。
另外,為什么我的條形圖之間的間距會變小?
最簡單的答案:
plt.xticks( x )
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.