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.43333005905, -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, 24.9061889648, 25.2130527496, 25.2830410004, 24.3628959656, 24.8488750458, 25.539434433, 25.0593471527, 27.4675426483, 27.2308082581, 24.7113208771, 25.5577297211, 25.8150978088, 25.5242824554, 26.1144638062, 26.6314525604, 26.332485199, 26.8232059479, 25.2991924286, 26.7113380432, 26.557466507, 26.3616294861, 26.0755062103, 27.4112701416, 27.3520183563, 26.8028297424, 27.2476978302, 27.534324646, 27.2034778595, 26.9729442596, 26.0462551117, 26.8081912994, 26.908082962, 25.2666225433]
    ly = [27.4810962677, 28.8500423431, 28.8246269226, 29.1994915009, 29.88322258, 27.9436683655, 26.8146209717, 28.2854194641, 27.1148548126, 30.6144733429, 28.9403953552, 30.3702335358, 30.2055301666, 29.8310012817, 30.0895881653, 28.5018634796, 28.6337127686, 29.8982486725, 29.2350940704, 28.8469028473, 30.0147590637, 29.6757392883, 29.7417221069, 30.3172016144, 29.3019046783, 29.1560783386, 29.1943569183, 29.6370487213, 31.0144519806, 29.4230709076, 29.1079292297, 28.1153450012, 29.171957016, 30.4724979401, 29.9674072266, 29.3979854584, 27.3481616974, 27.6976928711, 26.7552700043, 27.8960399628, 28.0646591187, 29.885011673, 26.1910648346, 26.2288837433, 29.6316223145, 29.3421859741, 28.9847698212, 29.0448360443, 28.8653907776, 28.6272373199, 29.0364208221, 28.5920791626, 28.8273677826, 30.0595531464, 29.2860488892, 30.1187438965, 29.6776771545, 30.867893219, 30.2446231842, 30.0953426361, 30.1778583527, 3.83387112617, 4.50870704651, 4.93131971359, 4.6545343399, 6.73423814774, 5.36260175705, 5.87900400162, 6.13863897324, 5.34195995331, 5.07684612274, 5.68586969376, 6.1027340889, 5.55645990372, 4.81935787201, 5.53062105179, 5.33130121231, 5.2288608551, 5.44512557983, 5.26086950302, 5.51278924942, 5.76212787628, 5.42846250534, 5.66052150726, 5.50753450394, 5.71055459976, 5.36737442017, 5.69235515594, 5.45446586609, 5.12829065323, 5.63220834732, 5.49666976929, 5.66061449051, 5.43731594086, 6.00030994415, 5.65290021896, 5.63237047195, 5.74980735779, 5.29807710648, 5.73972415924, 5.58069992065, 5.71600532532, 5.90563583374, 6.44614076614, 5.42868423462, 5.58056974411, 5.73130464554, 5.98108434677, 5.59527826309, 5.77340507507, 5.67755889893, 5.53397274017, 5.219622612, 5.68223905563, 5.21121120453, 5.4150929451, 5.24452638626, 5.57601547241, 5.90136432648, 5.51247358322, 5.43290615082, 5.59012031555, -3.74071002007, -5.25866365433, -7.03703165054, -7.69159507751, -7.43277740479, -6.04435062408, -6.84925460815, -7.68996334076, -7.02383184433, -7.01101779938, -6.99527263641, -6.82001447678, -7.60579681396, -7.42090559006, -6.90414857864, -7.64990663528, -6.49897480011, -6.87059259415, -7.0643119812, -6.46651887894, -6.94849634171, -6.53279352188, -6.49886465073, -6.78243398666, -6.35162067413, -6.64867401123, -7.09435272217, -6.24383401871, -6.57768917084, -6.76636743546, -6.44611406326, -6.10598039627, -6.21565818787, -7.24763298035, -6.02322769165, -5.92944908142, -6.08503627777, -6.07900857925, -5.88651227951, -6.33671855927, -4.24359750748, -5.67222452164, -5.42579174042, -6.47579669952, -6.210978508, -6.6082816124, -5.88621616364, -6.30484390259, -6.81608486176, -6.44417190552, -7.32409715652, -6.40404844284, -6.47909545898, -8.55440330505, -8.26213741302, -8.81159591675, -8.60329341888, -8.1914358139, -7.73334503174, -8.13174819946, -8.1451625824, 12.0506439209, 12.1816110611, 12.0142450333, 11.6686944962, 11.3408651352, 9.93625640869, 9.7035112381, 10.5965652466, 9.66590976715, 10.2689933777, 10.6383018494, 11.02729702, 10.75481987, 9.13800048828, 11.2828416824, 10.332862854, 10.6224584579, 10.1527385712, 9.41474246979, 10.348941803, 10.2559022903, 10.0812683105, 10.6171979904, 8.56242179871, 9.41495227814, 8.70387363434, 8.40291690826, 9.27769184113, 6.74157476425, 9.66269302368, 9.23078632355, 9.21887493134, 9.68165302277, 10.0570716858, 10.0647773743, 9.23720741272, 9.46548175812, 10.9746084213, 10.0672798157, 9.50922966003, 9.15139007568, 8.98347854614, 6.00443601608, 5.80842113495, 6.56068515778, 7.15742301941, 6.58682394028, 7.82994222641, 9.30323123932, 10.8191270828, 9.67613124847, 8.99267673492, 9.19123649597, 9.12201118469, 8.45175552368, 8.81405353546, 8.35607433319, 8.79576015472, 8.22607707977, 8.62314891815, 8.38526248932, 33.1045799255, 32.7910957336, 34.4569549561, 37.7044334412, 39.9702110291, 39.8982849121, 41.8386459351, 37.3762512207, 35.0133895874, 36.2136306763, 36.2647018433, 35.7437438965, 36.0703430176, 37.1286621094, 36.1804122925, 35.6159896851, 36.3608512878, 36.1786422729, 35.3091506958, 35.4324874878, 34.9277381897, 33.2732391357, 32.8940620422, 33.0893325806, 33.2461700439, 33.1796646118, 32.9248886108, 33.1398849487, 33.1479568481, 33.140789032, 32.473487854, 32.5002555847, 33.046787262, 34.0930557251, 33.0197029114, 36.5304107666, 34.9487380981, 32.285320282, 33.7723579407, 33.704662323, 33.2738685608, 34.626953125, 35.4097976685, 35.2191200256, 34.8415412903, 34.5710830688, 35.290927887, 35.169178009, 34.7100334167, 34.6661872864, 34.8268814087, 34.7441444397, 34.7775611877, 34.82264328, 34.7791404724, 35.4403762817, 34.5151405334, 35.0942420959, 34.758769989, 34.4876785278, 34.1459693909]
    lz = [1.29721734331, 3.46875738411, 3.45716248597, 3.94310471393, 4.76617190846, 1.87457805675, 0.616735245808, 2.60959624717, 3.04040345683, 5.65083060874, 3.64008248732, 5.01358639557, 5.21889825743, 4.77227240681, 4.72991004285, 3.10561560142, 3.52182164916, 5.35910707108, 4.37949662304, 3.86188582917, 4.87764178928, 5.38734833363, 4.86621916176, 5.37292770893, 4.11585328553, 4.19503737932, 4.41191809452, 5.18602968617, 6.82930258754, 5.93912577487, 4.43495476196, 2.52502183341, 3.64180625, 4.93881458967, 4.30528291584, 3.81025105552, 2.56711552683, 2.3666659812, 2.03728261224, 2.49820848999, 2.46873697407, 4.63040913671, 1.88399889298, 0.797642803709, 4.34260299728, 3.86972693661, 3.5025821681, 3.74509706802, 3.57278432794, 3.08123335062, 3.92638505973, 3.70965001905, 3.70572626639, 5.45516025769, 5.0643099552, 5.46066572833, 5.25280040528, 8.322762358, 8.1392622259, 8.51738733892, 7.74568037069, 2.37219958309, 4.20593105428, 4.11320797948, 5.68090689022, 5.52119598582, 5.13290035137, 6.428465033, 6.12967417961, 6.7754994141, 6.15168580981, 4.4581691219, 5.66635631344, 5.05943648302, 5.49611934999, 5.19094388264, 4.47664114674, 4.03487145525, 4.46936430101, 4.60637943615, 5.08440962136, 5.42652112268, 4.18406324215, 5.08542062432, 4.69863279662, 5.29584055558, 5.01741114478, 4.78448417773, 4.94638435737, 4.4546473083, 4.97380815075, 5.31379211764, 5.49867906646, 4.99597817916, 5.91573445793, 5.02209703514, 5.53288686379, 5.49414173833, 5.96956852949, 6.22408848026, 5.47279387832, 5.60322282435, 5.98551094607, 6.12539222766, 5.67077565792, 5.93147263991, 5.54909606108, 6.07560322206, 5.83648692837, 5.71128276878, 5.47976943514, 5.76212195619, 5.34506933704, 5.90812072951, 5.83129357222, 6.1184932004, 6.14644329913, 5.79100120514, 6.50451564109, 6.04700140091, 5.19391459056, 6.45998386459, 1.28511632005, 2.29954965017, 4.26008186233, 4.69941190847, 4.45825851783, 3.43875711103, 4.26536922719, 4.97310979376, 4.32795568462, 4.3411497914, 4.7005623038, 4.66165162917, 5.13855461506, 4.65279675554, 4.32168239071, 5.18464104427, 3.7982974025, 4.36836740052, 4.52190280947, 3.79412400701, 4.26043318769, 4.13341626608, 4.09722446318, 4.47111290764, 4.12385448096, 3.99159709624, 4.64748915619, 3.71813240427, 4.32185287769, 4.62978635409, 4.49038846721, 4.2876480969, 4.0964615845, 4.96700880761, 3.98324740467, 3.94012273302, 4.10978966049, 4.36484518226, 4.23106835094, 4.19097042581, 3.27604597978, 3.73025978115, 4.04485278116, 3.98951672565, 3.96426629142, 4.24953240147, 3.76239346578, 3.92768677421, 4.5849173538, 4.81354316594, 4.55516654204, 4.3875605145, 4.32863034521, 7.78122602155, 7.44451884927, 7.69920447534, 7.93236699051, 7.68979247079, 7.94764481825, 8.17896975736, 7.04873397103, 1.20048931593, 2.47951784987, 4.36233156038, 6.40710460945, 7.62167393923, 10.4127646075, 10.5240155105, 10.3778653087, 10.2404023455, 10.6309600717, 9.92194646537, 10.0212504745, 10.6730008823, 11.3884939107, 11.1334005616, 11.4112401916, 11.4002297484, 11.6634975074, 12.2804909564, 11.9943680149, 11.9612360672, 11.7984961149, 11.2587371902, 11.6366330999, 11.8294613028, 11.5484534764, 12.1965373368, 11.4693310321, 12.4994875482, 11.4301288134, 11.3161807436, 12.4166749068, 11.9680406241, 11.5389384844, 11.2755997605, 12.078814139, 11.6844993893, 11.9078110301, 13.3266449592, 13.36588268, 12.43397689, 11.9003534549, 13.6660058054, 14.0045572096, 13.8881504467, 13.9878065746, 13.0208846236, 12.9013693228, 12.8920937704, 13.5209495136, 12.9440612396, 11.7425493689, 12.1015668259, 13.5634287412, 11.584774674, 13.2816685211, 11.9712655143, 11.4622791463, 12.136257619, 12.6477651469, 12.4363773745, 3.66635253885, 3.97600333137, 5.37443520328, 11.5949667175, 11.7776735777, 11.6952800147, 13.3064945927, 12.1230153702, 8.71005143291, 10.5703594097, 10.5664686294, 9.63147162844, 9.65927565152, 11.4011499043, 11.3352237258, 10.7748512661, 11.3777224438, 9.5801080826, 9.62404016659, 9.31606237516, 8.05212152001, 3.10421706771, 2.70424194963, 2.96063313421, 2.89933003494, 3.11844971909, 2.83816337168, 3.44843411695, 3.18239097527, 3.41859638242, 3.22024511189, 2.28610803543, 3.20524850428, 4.28240310688, 3.07915567674, 8.59260483247, 6.0544767089, 2.39409672607, 3.98689141638, 4.11125252574, 3.60605481305, 5.3661940685, 6.01579158116, 5.70291757535, 6.30665237799, 4.69408360983, 6.26040680158, 6.39803068112, 5.74986087709, 6.07926008002, 7.01676916766, 6.72718905365, 5.94558173488, 6.57141137126, 6.64518194238, 7.01202052885, 6.05612590263, 5.22285835333, 5.51469070849, 5.41648188112, 4.20978756583]
    cx = [2.07680010796, 0.365800023079, 19.9474010468, 33.8526039124, 22.6242027283]
    cy = [26.2276000977, 5.19400024414, -3.03600001335, 12.952000618, 31.1811981201]
    
    
    
    # plot ligand data
    fig = pyplot.figure(figsize=(6,6))
    pyplot.scatter(lx, ly, c=lz, s=50, alpha=0.75)

    # plot cavity data
    pyplot.scatter(cx, cy, marker='+', edgecolor='r', s=100, linewidth=2)
    
    # plot a circle that fits the center of the cavities
    cavdata = zip(cx, cy)
    center = getCenter(cavdata)
    radius = getMeanDist(center, cavdata)
    circle = patches.Circle(center, radius, fill=False, linestyle='dashed')
    fig.gca().add_patch(circle)

    # set the axis range to obtain a square plot
    x1, x2 = pyplot.xlim()
    y1, y2 = pyplot.ylim()
    bounds = (min(x1,y1), max(x2,y2))
    pyplot.xlim(bounds)
    pyplot.ylim(bounds)

    for i in xrange(5):
        theta = i*1.3+1.5
        pyplot.annotate(str(i+1), (theta, radius-4), textcoords='polar', color='g')


    pyplot.show()


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

Reply via email to