17

到目前为止,我正在使用 Python 和 matplotlib 绘制绘图,我发现它们既庞大又灵活。

我唯一找不到的方法是让我的情节有多个网格。我查看了文档,但这只是线条样式......

我正在考虑类似两个地块,每个地块都有不同的网格,它们会重叠。

所以,例如我想制作这个图表:

替代文字 http://img137.imageshack.us/img137/2017/waittimeprobability.png

具有与此类似的网格标记:

替代文字 http://img137.imageshack.us/img137/6122/saucelabssauceloadday.png

我的意思是,更频繁的网格在重要点之间具有较浅的颜色。

4

1 回答 1

32

像这样的东西怎么样(改编自这里):

from pylab import *
from matplotlib.ticker import MultipleLocator, FormatStrFormatter

t = arange(0.0, 100.0, 0.1)
s = sin(0.1*pi*t)*exp(-t*0.01)

ax = subplot(111)
plot(t,s)

ax.xaxis.set_major_locator(MultipleLocator(20))
ax.xaxis.set_major_formatter(FormatStrFormatter('%d'))
ax.xaxis.set_minor_locator(MultipleLocator(5))

ax.yaxis.set_major_locator(MultipleLocator(0.5))
ax.yaxis.set_minor_locator(MultipleLocator(0.1))

ax.xaxis.grid(True,'minor')
ax.yaxis.grid(True,'minor')
ax.xaxis.grid(True,'major',linewidth=2)
ax.yaxis.grid(True,'major',linewidth=2)

show()

在此处输入图像描述

于 2009-11-13T16:44:44.110 回答