Matplotlib上的多个表格

2024-06-28 23:48:27 发布

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

我正在用Python和matplotlib制作绘图,到目前为止,我发现它们很大而且灵活。

我唯一找不到的办法就是让我的绘图有多个网格。 我研究过documentation,但那只是线条样式。。。

我在想两个图,每一个都有不同的网格,它们会重叠在一起。

因此,例如,我想制作这个图表:

Alt text http://img137.imageshack.us/img137/2017/waittimeprobability.png

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

Alt text http://img137.imageshack.us/img137/6122/saucelabssauceloadday.png

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


Tags: texthttp网格绘图pngmatplotlibdocumentation图表
1条回答
网友
1楼 · 发布于 2024-06-28 23:48:27

像这样的(改编自here)怎么样

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()

enter image description here

相关问题 更多 >