python - matplotlib 上的多个网格

标签 python matplotlib

我正在使用 Python 和 matplotlib 绘制绘图,我发现它们非常庞大且灵活,直到现在。

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

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

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

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

有一个和这个类似的网格标记:

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

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

最佳答案

这样的事情怎么样(改编自 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

关于python - matplotlib 上的多个网格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1729995/

相关文章:

python - matplotlib 散点图图例中缺少标签

python - "import pandas.io.data as web "给我一个错误,说没有 pandas.io.data 的模块名称

python - Python 中的打印问题

python - 属性错误: module 'tensorflow.contrib.slim' has no attribute 'model_analyzer'

python - matplotlib中图例中的重复项目?

python - pyplot : Closing a show() window doesn't continue code

Python:使用 matplotlib.pyplot 的奇怪 x 轴限制

python - matplotlib locator_params 或 set_major_locator 不工作

Python 字符串到列表的转换

python - python问题中的排序列表