OK, I've attached my sanitized example

Benjamin Root wrote:

> On Tue, Sep 11, 2012 at 9:29 AM, Neal Becker
> <ndbeck...@gmail.com> wrote:
> 
>> I tried a scatterplot with legend(loc='best'), but the legend
>> appears on the upper right, covering a data point.  There is nothing
>> anywhere
>> in the graph on the upper left, which is where 'best' should go.
>>
>>
> A small, self-contained example would be most useful.  The logic for 'best'
> isn't the greatest, but it should work in most cases.  If you could provide
> an example of where this blatantly breaks, it might uncover a bug.
> 
> Cheers!
> Ben Root
import numpy as np
import matplotlib.pyplot as plt

data_csv = '''\
mod,rate,esno
Z,2/3,3.09
Z,3/4,4.12
Z,4/5,4.75
Z,5/6,5.2
Z,8/9,6.21
Z,9/10,6.46
W,3/5,5.78
W,2/3,6.81
W,3/4,7.97
W,4/5,8.92
W,5/6,9.55
W,8/9,10.72
W,9/10,11
'''

from StringIO import StringIO
from pandas import read_csv
u = read_csv (StringIO (data_csv))
from fractions import Fraction

bit_per_sym = u.mod.map ({'Z' : 2, 'W' : 3})
bps_per_hz = bit_per_sym * u.rate.map (lambda s: float(Fraction(s))) / 1.05
u['X'] = bps_per_hz
V = u.esno - 10*np.log10(bit_per_sym*u.rate.map (lambda s: float(Fraction(s))))
u['V'] = V

stuff = u.groupby (['mod'])
import itertools
colors = itertools.cycle(['r','g','b','c','y','m','k']) 
markers = itertools.cycle(['o','s','v']) 

for case,res in stuff:
    print 'case:', case
    print 'res:', res

    plt.scatter (res.V, res.X, color=colors.next(), marker=markers.next(), label=case)
    for pts in zip (res.rate, res.V, res.X):
        print pts
        plt.annotate (pts[0], xy=(pts[1],pts[2]))
 
F_csv = '''\
mod,rate,F,V
Z,2/3,1.2375,2.0
Z,3/4,1.25,2.6
Z,8/9,1.24,4.0
W,2/3,1.3125,5
W,4/5,1.3125,6.4
'''

v = read_csv (StringIO (F_csv))

bit_per_sym = v.mod.map ({'Z' : 2, 'W' : 3})
bps_per_hz = bit_per_sym * v.F * v.rate.map (lambda s: float(Fraction(s))) / 1.05
v['X'] = bps_per_hz
stuff = v.groupby (['mod'])
for case,res in stuff:
    print 'case:', case
    print 'res:', res

    plt.scatter (res.V, res.X, color=colors.next(), marker=markers.next(), label='F-'+case)

    for pts in zip (res.rate, res.V, res.X, res.F):
        print pts
        plt.annotate ('%s,%s'%(pts[0],pts[3]), xy=(pts[1],pts[2]))
                      
plt.grid()
plt.legend(loc='best')
plt.show()

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to