This code runs on python3, but on python2 I get:
Traceback (most recent call last):
  File "per_vs_lambda.py", line 35, in <module>
    ax.set_xlabel (' ')
  File "/usr/lib64/python2.7/site-packages/matplotlib/axes/_axes.py", line 
179, in set_xlabel
    return self.xaxis.set_label_text(xlabel, fontdict, **kwargs)
  File "/usr/lib64/python2.7/site-packages/matplotlib/axis.py", line 1480, 
in set_label_text
    self.label.set_text(label)
  File "/usr/lib64/python2.7/site-packages/matplotlib/text.py", line 1028, 
in set_text
    self._text = '%s' % (s,)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xce in position 0: 
ordinal not in range(128)


#!/usr/bin/python
# -*- coding: utf-8 -*-
data='''carriers,lambda,per
1,7,1.3e-4
1,8,3.0e-4
1,9,.0014
8,7,4.8e-4
8,8,1.3e-3
8,9,.0075
'''

import pandas as pd
try:
    from StringIO import StringIO
except ImportError:
    from io import StringIO
df = pd.read_csv (StringIO (data))
g = df.groupby ('carriers')
import matplotlib.pyplot as plt

import matplotlib as mpl
#mpl.rcParams['font.family'] = 'stix'
mpl.rc('font', family='DejaVu Sans')
#mpl.rc('font', family='stix')

import itertools
markers = itertools.cycle(['o','s','v']) 

fig = plt.figure() 
ax = fig.add_subplot(111)
for c, stuff in g:
    plt.semilogy (stuff['lambda'].values, stuff['per'].values, 
label='carriers=%s'%c, marker=next(markers))

plt.legend (loc='best')
ax.set_xlabel (' ') <<< this invisible character is a small greek lambda
ax.set_ylabel ('per')
plt.grid(which='major', linestyle='solid')
plt.grid(which='minor', linestyle='dashed') 
plt.savefig ('per_vs_lambda.pdf')






------------------------------------------------------------------------------
Don't Limit Your Business. Reach for the Cloud.
GigeNET's Cloud Solutions provide you with the tools and support that
you need to offload your IT needs and focus on growing your business.
Configured For All Businesses. Start Your Cloud Today.
https://www.gigenetcloud.com/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to