major_minor_demo2.py
来自「非原创。很好的python例子」· Python 代码 · 共 27 行
PY
27 行
#!/usr/bin/env python"""Set the major ticks on the ints and minor ticks on multiples of 0.2"""from pylab import *from matplotlib.ticker import MultipleLocator, FormatStrFormattermajorLocator = MultipleLocator(1)majorFormatter = FormatStrFormatter('%d')minorLocator = MultipleLocator(.2)t = arange(0.0, 10.0, 0.01)s = sin(2*pi*t)*exp(-t*0.01)ax = subplot(111)plot(t,s)ax.xaxis.set_major_locator(majorLocator)ax.xaxis.set_major_formatter(majorFormatter)#for the minor ticks, use no labels; default NullFormatterax.xaxis.set_minor_locator(minorLocator) show()
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?