您的位置:首页 > 编程语言 > PHP开发

pylab/matplotlib 日期标签控制

2013-08-26 17:50 169 查看
今天遇到了同样的问题,经过搜索,搜到下面这篇文章

Today I struggled a bit with
pylab's plot_date function and overlapping date tick labels:



After some googling, I found that pylab offers
nice flexible date tick control and formatting. I added a date tick locator and a date formatter to the mix as follows:

import pylab
import matplotlib
import matplotlib.dates

fig = pylab.figure()
ax = fig.gca()

# Plotting stuff here ...
ax.plot_date(dates, values, 'b.-')

# Set major x ticks on Mondays.
ax.xaxis.set_major_locator(
matplotlib.dates.WeekdayLocator(byweekday=matplotlib.dates.MO)
)
ax.xaxis.set_major_formatter(
matplotlib.dates.DateFormatter('%a %d\n%b %Y')
)


and now I have this plot



转自:http://stefaanlippens.net/pylab_date_tick_control
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: