custom_ticker1.py

来自「非原创。很好的python例子」· Python 代码 · 共 30 行

PY
30
字号
#!/usr/bin/env python"""The new ticker code was designed to explicity support user customizedticking.  The documentationhttp://matplotlib.sourceforge.net/matplotlib.ticker.html details thisprocess.  That code defines a lot of preset tickers but was primarilydesigned to be user extensible.In this example a user defined function is used to format the ticks inmillions of dollars on the y axis"""from matplotlib.ticker import FuncFormatterfrom pylab import *x =     arange(4)money = [1.5e5, 2.5e6, 5.5e6, 2.0e7]def millions(x, pos):    'The two args are the value and tick position'    return '$%1.1fM' % (x*1e-6)formatter = FuncFormatter(millions)ax = subplot(111)ax.yaxis.set_major_formatter(formatter)bar(x, money)xticks( x + 0.5,  ('Bill', 'Fred', 'Mary', 'Sue') )show()

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?