def plot_csv(target_dir='', columns=0, sep=' ', separate=False, title=None):
if type(columns) is not list:
columns = [columns]
title = title or 'LDA Inference'
xlabel = 'Iterations'
markers = cycle([ '+', '*', ',', 'o', '.', '1', 'p', ])
if not separate:
fig = plt.figure()
ax1 = fig.add_subplot(111)
ax1.set_xlabel(xlabel)
ax1.set_title(title)
for column in columns:
if separate:
fig = plt.figure()
plt.title(title)
plt.xlabel('xlabel')
ax1 = plt.gca()
filen = os.path.join(os.path.dirname(__file__), "../PyNPB/data/", target_dir)
with open(filen) as f:
data = f.read()
data = filter(None, data.split('\n'))
data = [x.strip() for x in data if not x.startswith(('#', '%'))]
ll_y = [row.split(sep)[column] for row in data]
ylabel, label = tag_from_csv(column)
ax1.set_ylabel(ylabel)
#ax1.plot(ll_y, c='r',marker='x', label='log likelihood')
ax1.plot(ll_y, marker=next(markers), label=label)
leg = ax1.legend()
plt.draw()
评论列表
文章目录