Hi,

On Thu, 2008-07-17 at 07:47 -0700,
[EMAIL PROTECTED] wrote:
> Just because the discussion about clabel started, I want to post a
> short 
> snipplet of code that I found useful. It was some sort of hack to get
> a 
> nicer float formating for contours: contour lines represented
> confidence 
> levels of 1, 2.5, 5 and 10 per cent, and I wanted a labeling exactly
> as 
> I have written it here now. So, fmt='%.1f\%%' would have resulted in 
> 1.0% 2.5% 5.0% ... but I wanted 1% 2.5% 5% ...
> 
> So this was my solution:
> 
> 
> # some kind of hack: a nicer floating point formating
> class nf(float):
>      def __repr__(self):
>          str = '%.1f' % (self.__float__(),)
>          if str[-1]=='0':
>              return '%.0f' % self.__float__()
>          else:
>              return '%.1f' % self.__float__()
> 
> levels = [nf(val) for val in [1.0, 2.5,5.0,10.0] ]
> 
> pylab.clabel(cs, inline=True, fmt='%r \%%')
> 
> 
> As I said, it's sort of a hack but it works! It might not be worth to 
> add this to mpl, but probably as an example ...!?
> 
> Manuel

Along these lines, I have been thinking that it would be a simple
addition to allow fmt to be a dictionary (as an alternative to a string)
that matches contour levels with the desired text.  This would allow
users to label contours with arbitrary strings, which is occasionally
useful.  If there is interest, I will add this feature.

Cheers,
David



-- 
**********************************
David M. Kaplan
Charge de Recherche 1
Institut de Recherche pour le Developpement
Centre de Recherche Halieutique Mediterraneenne et Tropicale
av. Jean Monnet
B.P. 171
34203 Sete cedex
France

Phone: +33 (0)4 99 57 32 27
Fax: +33 (0)4 99 57 32 95
http://www.ur097.ird.fr/team/dkaplan/index.html
**********************************


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel

Reply via email to