>>>>> "Alfredo" == Alfredo Sotelo <[EMAIL PROTECTED]> writes:

    Alfredo> Hi, Does anyone know how to use FuncFormatter class to
    Alfredo> translate the tick labels using a user defined function?

    Alfredo>  I have on my xaxis the code of my weather stations and I
    Alfredo> have defined a function to replace them with their
    Alfredo> station names. The function uses just a dictionary.

    Alfredo>  When I tried to apply "FuncFormatter(func)" it didn't
    Alfredo> work.

    Alfredo>  No results found searching for examples or recipes :(

mpl> grep -l FuncFormatter examples/*.py
examples/custom_ticker1.py

#!/usr/bin/env python
from matplotlib.ticker import FuncFormatter
from 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()

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to