From: John H. <jdh...@ac...> - 2004-05-04 14:39:41
|
>>>>> "Humufr" == Humufr <hu...@ya...> writes: Humufr> There are something I did't see in the list (but perhaps Humufr> it's possible to do now) and that I think will be useful Humufr> for astronomer. it's to plot an image with axes in Humufr> astronomical unit (RA and Dec) Humufr> like this function in pgplot: Humufr> http://www.astro.caltech.edu/~tjp/pgplot/subroutines.html#PGTBOX Humufr> thanks for this software who are very good, The new ticker code was designed to support exactly this kind of application. The documentation http://matplotlib.sourceforge.net/matplotlib.ticker.html details this process. That code defines a lot of preset tick locators and formatters but was primarily designed to be user extensible. Since I'm not an astronomer, I'm probably not the best person to write this, but it would be fairly easy to subclass matplotlib.ticker.Locator and matplotlib.ticker.Formatter to provide exactly this functionality. Here is a simple example showing how to use a user defined function to format the ticks (millions of dollars in this case) from matplotlib.ticker import FuncFormatter from matplotlib.matlab 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) ax.set_xticks( x + 0.5) ax.set_xticklabels( ('Bill', 'Fred', 'Mary', 'Sue') ) show() In you case however, you would probably want to define new classes that derive from Locator and Formatter (you can follow the example of the many custom locators and formatters in matplotlib.ticker). If you do, please send the classes in with an example so I can include them in the standard distribution. If you don't want to do this, I'm sure one of the stsci guys will do this since they have expressed interest in this as well. JDH |