我正在尝试创建用于绘制多个数据文件的循环。
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import glob
import os
pathf1 = r'/home/foo/condt/'
allfiles1 = glob.glob(pathf1 + '/*.csv')
fig1 = plt.figure()
for filee_ in allfiles1:
dfp = pd.read_csv(filee_, sep=',', encoding='utf-8')
ax = plt.subplot(111)
ax.plot(dfp['col3'], dfp['col2'], ls = '-', color='red', marker='x', markersize = 25.0)
ax.errorbar(dfp['col1'], dfp['col2'], yerr=dfp['PN_6_FLUX_ERR'], ls='None', marker = '.')
ax.set_xlim((dfp['col1'].min()-0.1*(dfp['col1'].max()-dfp['col1'].min())), ((dfp['col1'].max()+0.1*(dfp['col1'].max()-dfp['col1'].min()))))
ax.set_ylim((dfp['col2'].min()-dfp['col2'].max()),((dfp['col2'].max()/2.0)+dfp['col2'].max())
ax.grid()
plt.xticks(dfp['col1'])
plt.yticks(dfp['col2'])
plt.xlabel('col1')
plt.ylabel('col2')
plt.title('col1 vs. col2')
filenamee = ''+ str('%02s' %filee_)+'.png'
plt.savefig(filenamee, dpi=600)
plt.clf()
plt.show()
当我运行代码时,我得到了这个:
plt.savefig(filenamee,dpi = 600)
ValueError:无法将float NaN转换为整数
文件中的列,
col1 col2 col3
3.39895E-12 52459.7796644
3.62529E-12 52461.7358623
3.67719E-12 52501.6052951
2.26977E-11 56340.081624
3.38851E-11 53574.1580939 53574.1580939
当我从代码中删除滴答时,一切都会正常......但我需要在图表中打勾。我该如何解决这个问题?
答案 0 :(得分:1)
我找到了解决方案。问题来源是ListView
库的版本。我认为这是一种错误。要解决此问题,您必须使用下面的终端命令更新$goto = isset($_GET['goto']) ? $_GET['goto']:null;
$id = isset($_GET['id']) ? $_GET['id']:0;
if($goto == 'profile' && $id != 0){
require_once('profile.php');
}
库。
matplotlib