I guess you're missing vertical and horizontal alignment.
Also, your font properties were not set correctly. The 4th argument of
the text function is a color.


fontdict2 = {'fontweight':'light',
             'color': 'r',
             'fontsize':fontsize}
fp = FontProperties(fontdict2)

labels = plt.clabel(CS, inline=1, fontsize=fontsize,colors='k')
for label in labels:
    ltext = label.get_text()
    lx,ly = label.get_position()
    lrot=label.get_rotation()
    va, ha = label.get_va(), label.get_ha()
    t = plt.text(lx,ly,ltext, fontproperties=fp,
                 rotation=lrot,va=va, ha=ha)

You may simply use update_from() method.

Anyhow, I'm not sure if you can put dorpshadow effect this way.
Changing font weight usually changes the overall size of each glyph.

Regards,

-JJ


On Tue, Jan 6, 2009 at 10:20 AM, Michael Hearne <mhea...@usgs.gov> wrote:
> Is the list of return values from the clabel() function supposed to
> represent the position and orientation of the contour labels?  I have a
> script below where I try to re-draw the contour labels using the Text
> objects in the list returned from clabel(), and they do not line up in
> my output.  I'm using Matplotlib version 0.98.5.1, revision 6622.
>
> If this is intentional, is there some way of retrieving the actual
> position/orientation of the contour labels?  I'm trying to make a
> drop-shadow effect for those labels, and I need to know where they are
> exactly for my code to work.
>
> Sample script:
> #!/usr/bin/env python
> import matplotlib
> import numpy as np
> import matplotlib.cm as cm
> import matplotlib.mlab as mlab
> import matplotlib.pyplot as plt
> import math
>
> matplotlib.rcParams['xtick.direction'] = 'out'
> matplotlib.rcParams['ytick.direction'] = 'out'
>
> delta = 0.025
> x = np.arange(-3.0, 3.0, delta)
> y = np.arange(-2.0, 2.0, delta)
> X, Y = np.meshgrid(x, y)
> Z1 = mlab.bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0)
> Z2 = mlab.bivariate_normal(X, Y, 1.5, 0.5, 1, 1)
> # difference of Gaussians
> Z = 10.0 * (Z2 - Z1)
>
> f=plt.figure(facecolor='g')
> ax = plt.gca()
> ax.set_axis_bgcolor('g')
> CS = plt.contour(X, Y, Z)
> xt = plt.xticks()
> yt = plt.yticks()
>
> fontsize = 10
> fontdict2 = {'fontweight':'light',
>             'color': 'r',
>             'fontsize':fontsize}
> labels = plt.clabel(CS, inline=1, fontsize=fontsize,colors='k')
> for label in labels:
>    ltext = label.get_text()
>    lrot = label.get_rotation()
>    lx,ly = label.get_position()
>    plt.text(lx,ly,ltext,fontdict2,rotation=lrot)
>
> plt.savefig('output.png')
>
>
> ------------------------------------------------------------------------------
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>

------------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It is the best place to buy or sell services for
just about anything Open Source.
http://p.sf.net/sfu/Xq1LFB
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to