Bala subramanian <bala.biophys...@gmail.com> writes:
> Kindly see the attached small test.dat file. I have make a plot with
> this data. But my data does nt have numerical values but has
> characters like B, T etc. So i hve give color codings for these
> characters and plot the data. Like use yellow for B, red for T etc.
> Kindly help me to do it with matplotlib.
Perhaps this will get you started:
from matplotlib import pyplot as plt
colors = {'B': '#aaaa22', 'T': '#1111aa', '0': '#cccccc'}
fontdict = {'fontsize': 8}
fig = plt.figure()
ax = fig.add_subplot(111)
f = open('test.dat', 'rt')
header = f.next().split()
header = [float(h) for h in header[1:]]
minx, maxx = float('Inf'), -float('Inf')
for line in f:
fields = line.split()
x = float(fields[0])
if x < minx: minx = x
if x > maxx: maxx = x
for i,ch in enumerate(fields[1:]):
ax.text(x, header[i], ch, fontdict, color=colors[ch])
ax.set_xlim(minx, maxx+1)
ax.set_ylim(min(header)-.5, max(header)+.5)
plt.show()
--
Jouni K. Seppänen
http://www.iki.fi/jks
------------------------------------------------------------------------------
This SF.net email is sponsored by:
High Quality Requirements in a Collaborative Environment.
Download a free trial of Rational Requirements Composer Now!
http://p.sf.net/sfu/www-ibm-com
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users