Re: [Matplotlib-users] text annotation

2010-12-21 Thread Benoist Laurent
Nice!
Still some stuff to enhance but got it!

Thanks a lot.
Ben

Le 19 déc. 10 à 05:30, Jae-Joon Lee a écrit :

 I don't think polar is a good fit for your case. Instead, you can
 simply use data coordinate with explicit coordinate transformation.
 Try something like;

for i in xrange(5):
theta = i*1.3+1.5
xx = center[0]+(radius-4)*math.cos(theta)
yy = center[1]+(radius-4)*math.sin(theta)
pyplot.annotate(str(i+1), (xx, yy), color='g', va=center,  
 ha=center)

 -JJ



 On Thu, Dec 16, 2010 at 5:27 PM, Benoist Laurent beno...@ibpc.fr  
 wrote:
 Sorry for the delay.
 This is the script is used (modified so that it include the data).



 Le 15 déc. 10 à 16:50, Benjamin Root a écrit :

 On Wed, Dec 15, 2010 at 9:46 AM, Benoist Laurent beno...@ibpc.fr  
 wrote:

 Hi all,
 I'm still a bit stuck with this probleme of polar annotation.
 Let me present the problem in a different way.
 I've got the center of my circle, its radius and even some points  
 on the
 circle.
 Actually, I'd like to annotate these points (red crosses in the  
 joined
 picture).
 How would you do that?
 My best try gave me the green numbers.
 Thanks in advance,
 Ben


 Can you include the source code (if it is simple) that you used to  
 generate
 this example, and we could probably help you out.

 Ben Root



 --
 Lotusphere 2011
 Register now for Lotusphere 2011 and learn how
 to connect the dots, take your collaborative environment
 to the next level, and enter the era of Social Business.
 http://p.sf.net/sfu/lotusphere-d2d
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users





--
Lotusphere 2011
Register now for Lotusphere 2011 and learn how
to connect the dots, take your collaborative environment
to the next level, and enter the era of Social Business.
http://p.sf.net/sfu/lotusphere-d2d
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] text annotation

2010-12-18 Thread Jae-Joon Lee
I don't think polar is a good fit for your case. Instead, you can
simply use data coordinate with explicit coordinate transformation.
Try something like;

for i in xrange(5):
theta = i*1.3+1.5
xx = center[0]+(radius-4)*math.cos(theta)
yy = center[1]+(radius-4)*math.sin(theta)
pyplot.annotate(str(i+1), (xx, yy), color='g', va=center, ha=center)

-JJ



On Thu, Dec 16, 2010 at 5:27 PM, Benoist Laurent beno...@ibpc.fr wrote:
 Sorry for the delay.
 This is the script is used (modified so that it include the data).



 Le 15 déc. 10 à 16:50, Benjamin Root a écrit :

 On Wed, Dec 15, 2010 at 9:46 AM, Benoist Laurent beno...@ibpc.fr wrote:

 Hi all,
 I'm still a bit stuck with this probleme of polar annotation.
 Let me present the problem in a different way.
 I've got the center of my circle, its radius and even some points on the
 circle.
 Actually, I'd like to annotate these points (red crosses in the joined
 picture).
 How would you do that?
 My best try gave me the green numbers.
 Thanks in advance,
 Ben


 Can you include the source code (if it is simple) that you used to generate
 this example, and we could probably help you out.

 Ben Root



 --
 Lotusphere 2011
 Register now for Lotusphere 2011 and learn how
 to connect the dots, take your collaborative environment
 to the next level, and enter the era of Social Business.
 http://p.sf.net/sfu/lotusphere-d2d
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users



--
Lotusphere 2011
Register now for Lotusphere 2011 and learn how
to connect the dots, take your collaborative environment
to the next level, and enter the era of Social Business.
http://p.sf.net/sfu/lotusphere-d2d
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] text annotation

2010-12-16 Thread Benoist Laurent
Sorry for the delay.This is the script is used (modified so that it include the data).	

from matplotlib import pyplot
from matplotlib import patches
import math

def getCenter(points):
Return the center of a list of 2D points.
meanX = sum(p[0] for p in points) / len(points)
meanY = sum(p[1] for p in points) / len(points)
return (meanX, meanY)

def dist(p1, p2):
Return the distance between two points.\
 Points can be either 2D or 3D.
s2 = 0.0
for i, dim1 in enumerate(p1):
s2 += (dim1 - p2[i])**2
return math.sqrt(s2)

def getMeanDist(ref, points):
Return the mean distance between a reference point and a list of \
 points.
d = [dist(ref, p) for p in points]
return sum(d) / len(d)


if __name__ == '__main__':


lx = [2.13796782494, 0.22932203114, 0.145705774426, -0.1842751652, -0.472284257412, 1.66362369061, 2.16047716141, 1.47219955921, 0.703634023666, -1.15651118755, 0.443440586329, -0.292924255133, -0.576901197433, -0.390790998936, -0.453659176826, -0.0308310128748, 0.567431628704, -0.788715064526, -0.170957371593, -0.0500493347645, -0.635111093521, -0.949955403805, -1.0446549654, -1.09050607681, -0.334621369839, -0.256768316031, -0.528183162212, -0.221842378378, -1.81420075893, -1.08557665348, -0.57961076498, 0.432336330414, -0.0662814080715, -0.370493412018, 0.125144153833, 1.28159570694, 1.84332048893, 1.14498448372, 1.67104315758, 1.42439639568, 0.82164734602, -0.587348818779, 0.760407328606, 1.27920556068, -0.61829417944, -0.18117390573, -0.0751572549343, -0.350429683924, 0.345632463694, 0.323070138693, -0.475901484489, -0.726973831654, -0.343768119812, -0.796733736992, -0.830528855324, -1.045976758, -1.09633731842, -2.4005905, -2.86712360382, -3.10275816917, -3.01660752296, -1.34393537045, -1.94433999062, -2.16338896751, -3.34179592133, -0.19719530642, -1.1443066597, -1.08435976505, -1.39720845222, -2.89352178574, -2.2695646286, -1.57835280895, -1.81462919712, -1.89711308479, -2.32298707962, -2.0290055275, -1.45719373226, -1.57886171341, -1.65614414215, -1.4572674036, -1.51952528954, -1.88826346397, -2.22109389305, -1.71397793293, -1.71507167816, -1.70611810684, -1.56743752956, -1.85161161423, -1.6463187933, -1.79676258564, -1.87860679626, -2.90355992317, -1.84876096249, -2.07646965981, -2.05375623703, -1.71399760246, -2.81210660934, -1.78234100342, -2.53161597252, -2.66990470886, -2.39481759071, -2.04717803001, -1.93592202663, -2.37386870384, -2.39932227135, -2.04974675179, -1.92444729805, -2.54312872887, -2.16789412498, -2.93449926376, -2.78199458122, -2.67508721352, -1.9028263092, -2.93164873123, -2.31925606728, -2.98324871063, -2.68316316605, -2.91516590118, -3.1617205143, -2.52871823311, -2.16317343712, -3.33456754684, 19.1367740631, 19.6861019135, 19.7093486786, 19.8942642212, 19.8867950439, 19.87865448, 19.4970397949, 20.2397651672, 19.4614696503, 19.9221191406, 19.7497997284, 19.6925258636, 19.3745632172, 19.3739128113, 19.5682678223, 19.604133606, 19.74168396, 19.603395462, 20.053232193, 19.7705841064, 19.5930023193, 19.8512248993, 19.6046142578, 20.1397628784, 19.9803371429, 19.7125339508, 19.9095001221, 19.728099823, 19.8760719299, 20.1098461151, 19.6742668152, 20.1753902435, 20.0182418823, 19.8330516815, 20.1489067078, 19.5577068329, 19.9162006378, 19.7167301178, 20.0771312714, 19.7205791473, 20.2147369385, 20.1147880554, 20.0389518738, 20.1278991699, 19.7525215149, 19.9678668976, 19.9451332092, 20.5374622345, 19.5659732819, 20.7870616913, 20.4983119965, 20.4722671509, 20.3699855804, 20.4146499634, 20.6225090027, 20.6489887238, 20.9176940918, 20.4313163757, 20.9441738129, 20.7304534912, 20.2121162415, 34.6434783936, 35.7543067932, 37.1368217468, 39.034198761, 39.5439300537, 41.0436935425, 40.4959945679, 41.0163993835, 40.7507781982, 41.2522659302, 40.2168617249, 40.7332229614, 39.8335456848, 39.0498046875, 40.0605392456, 37.2514038086, 38.2259063721, 38.196849823, 38.1231460571, 37.7521896362, 39.277507782, 38.6683502197, 38.2704620361, 38.2063293457, 38.067489624, 38.6640090942, 38.5982666016, 38.5062294006, 36.9058113098, 37.9915237427, 37.6883964539, 38.0861587524, 38.3267974854, 37.8808479309, 38.5241470337, 38.6476554871, 37.7013282776, 37.6500053406, 38.2657966614, 36.6454200745, 37.444229126, 37.0459251404, 38.2217788696, 39.1504516602, 38.24269104, 38.0813293457, 37.9510307312, 39.0387458801, 42.2573318481, 40.275932312, 40.8754386902, 40.0514564514, 39.403213501, 39.3534126282, 39.8045806885, 39.3862571716, 39.2270507812, 39.6057128906, 39.2035255432, 39.6626663208, 40.0390663147, 25.4331626892, 24.387714386, 26.7786521912, 27.871843338, 29.3762130737, 29.6802787781, 29.8811683655, 31.9314346313, 29.6904697418, 30.3535175323, 29.1959037781, 28.9361419678, 29.3124370575, 27.9452018738, 27.7858276367, 28.2697582245, 28.1843299866, 28.5413455963, 30.4542121887, 29.6431770325, 28.966758728, 24.7452583313, 24.3427753448, 24.8653335571, 24.6588020325, 24.9432849884, 24.599275589, 25.060792923, 

Re: [Matplotlib-users] text annotation

2010-12-15 Thread Benjamin Root
On Wed, Dec 15, 2010 at 9:46 AM, Benoist Laurent beno...@ibpc.fr wrote:

 Hi all,

 I'm still a bit stuck with this probleme of polar annotation.
 Let me present the problem in a different way.

 I've got the center of my circle, its radius and even some points on the
 circle.
 Actually, I'd like to annotate these points (red crosses in the joined
 picture).
 How would you do that?

 My best try gave me the green numbers.

 Thanks in advance,
 Ben



Can you include the source code (if it is simple) that you used to generate
this example, and we could probably help you out.

Ben Root
--
Lotusphere 2011
Register now for Lotusphere 2011 and learn how
to connect the dots, take your collaborative environment
to the next level, and enter the era of Social Business.
http://p.sf.net/sfu/lotusphere-d2d___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] text annotation

2010-11-26 Thread Alan G Isaac
On 11/26/2010 8:12 AM, Benoist Laurent wrote:
 How can I manage the annotation of points forming a circle if I have
 their coordinates?

http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.annotate

http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.text

http://matplotlib.sourceforge.net/examples/api/joinstyle.html

hth,
Alan Isaac

--
Increase Visibility of Your 3D Game App  Earn a Chance To Win $500!
Tap into the largest installed PC base  get more eyes on your game by
optimizing for Intel(R) Graphics Technology. Get started today with the
Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs.
http://p.sf.net/sfu/intelisp-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] text annotation

2010-11-26 Thread Benoist Laurent
Thank you for your answer.
I read the text and annotate manual pages.

I don't understand how the polar  xycoords/textcoords works.
I guess I should use this but its not clear to me.




Le 26 nov. 10 à 14:13, Alan G Isaac a écrit :

 On 11/26/2010 8:12 AM, Benoist Laurent wrote:
 How can I manage the annotation of points forming a circle if I have
 their coordinates?

 http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.annotate

 http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.text

 http://matplotlib.sourceforge.net/examples/api/joinstyle.html

 hth,
 Alan Isaac

 --
 Increase Visibility of Your 3D Game App  Earn a Chance To Win $500!
 Tap into the largest installed PC base  get more eyes on your game by
 optimizing for Intel(R) Graphics Technology. Get started today with  
 the
 Intel(R) Software Partner Program. Five $500 cash prizes are up for  
 grabs.
 http://p.sf.net/sfu/intelisp-dev2dev
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users



--
Increase Visibility of Your 3D Game App  Earn a Chance To Win $500!
Tap into the largest installed PC base  get more eyes on your game by
optimizing for Intel(R) Graphics Technology. Get started today with the
Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs.
http://p.sf.net/sfu/intelisp-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Text annotation misaligned with png backend.

2009-10-30 Thread Jae-Joon Lee
I don't see such problem in my installations.
I may be wrong but It seems to me that it is a font issue (I believe
you're not using usetex mode).

Can you try to use other fonts?

For example, my current installation picks up the following font (Vera Serif?).

In [10]: matplotlib.font_manager.findfont(None)
Out[10]: 
'/astro/research/jul27/local/lib/python2.5/site-packages/matplotlib/mpl-data/fonts/ttf/VeraSe.ttf'

Regards,

-JJ



2009/10/30 Johan Grönqvist johan.gronqv...@gmail.com:
 Hello List,

 I am so far happy with the output form matplotlib, but I recently started
 annotating my plots, and when saving to png-format, the annotations do not
 look very nice. When saving to eps format, I do not see the same problems.

 Saving to eps and converting to png seems to be a good workaround for me.

 The problem is that the letters in the same word (on the same line) are not
 aligned, some are drawn to far up or down.

 png and eps figures are attached. Example script and version number (0.99.0)
 below.

 Am I misusing matplotlib? Is this a bug?


 Regards

 johan








 Minimal example:
 ---
 import matplotlib.pyplot as plt
 import numpy as np

 plt.figure()

 x = [0]
 plt.plot(x, x)

 plt.annotate(units are important, $7.64358$,
 $\\frac{\mathrm{k}\mathrm{m}}{\mathrm{s^2}}$,
             xy = (0,0),
             xycoords = data,
             xytext = (0.2, 0.6),
             textcoords = figure fraction,
             arrowprops = dict(arrowstyle = -,
                               connectionstyle = arc))


 plt.savefig(pyplot_text.png)
 plt.savefig(pyplot_text.eps)
 plt.show()
 ---


 Expected result: An empty plot with a nice annotation on screen, in a
 png-file, and in an eps-file

 Result: Empty plots with annotation displaying differently in the three
 cases. In the png file, the letters u and r  and the digit 7 appear slightly
 above the correct position, and the m in the unit km appears slightly below
 the correct position. In the screen output, the m is correct, but the u and
 r show the same problem as in the png file. In the eps file, all seems to be
 well.

 My os is debian (testing), and I obtain matplotlib and all related software
 from the debian repositories.

 jo...@johan-laptop:~$ uname -a
 Linux johan-laptop 2.6.30-2-amd64 #1 SMP Fri Sep 25 22:16:56 UTC 2009 x86_64
 GNU/Linux
 jo...@johan-laptop:~$ python -c import matplotlib; print
 matplotlib.__version__
 0.99.0





 --
 Come build with us! The BlackBerry(R) Developer Conference in SF, CA
 is the only developer event you need to attend this year. Jumpstart your
 developing skills, take BlackBerry mobile applications to market and stay
 ahead of the curve. Join us from November 9 - 12, 2009. Register now!
 http://p.sf.net/sfu/devconference
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users



--
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users