bioplanet 0 Newbie Poster

Hi all,

I have the following script for creating scatter plots and I was wondering if there is a way of adding the legends also for each dot in the plot (i.e. Method1, Method2 etc)

#!/usr/bin/env python

import sys,re,os;
import matplotlib as mpl;
import matplotlib.pyplot as plt;

datafile = './data.dat';


fig = plt.figure();
ax = fig.add_subplot(1,1,1);

flh = open(datafile);
for line in flh :
    lstLine = line.strip().split();
    x = float(lstLine[0]);
    y = float(lstLine[1]);
    ax.plot(x, y, 'bo', markersize=2.5); 
flh.close();

x_lim = (0,1);
y_lim = (0,1);

ax.plot(x_lim, y_lim,'k-');

ax.set_xlim(x_lim);
ax.set_ylim(y_lim);

ax.set_xlabel("% correct");
ax.set_ylabel('% high');

pic_format = 'png';

plt.savefig('./data.' + pic_format, format = pic_format);

My data file is

0.52	0.747777258
0.63	0.806738418
0.62	0.764595983
0.76	0.909816815
0.64	0.795804196
0.4	0.606457651
0.64	0.774450164
0.59	0.712681329
0.66	0.781818182
0.75	0.911421911
0.53	0.676456876
0.74	0.907226107
0.68	0.796602171
0.79	0.966899767
0.83	0.939393939
0.79	0.945920746

and what I would like to do is to have a legend for each dot, i.e, using the "complete" file:

Method1	0.52	0.747777258
Method2	0.63	0.806738418
Method3	0.62	0.764595983
Method4	0.76	0.909816815
Method5	0.64	0.795804196
Method6	0.4	0.606457651
Method7	0.64	0.774450164
Method8	0.59	0.712681329
Method9	0.66	0.781818182
Method10	0.75	0.911421911
Method11	0.53	0.676456876
Method12	0.74	0.907226107
Method13	0.68	0.796602171
Method14	0.79	0.966899767
Method15	0.83	0.939393939
Method16	0.79	0.945920746

Can this be done somehow?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.