Anaconda Python 3.6 Matplotlib非法字符串错误

时间:2018-12-14 10:07:15

标签: python python-3.x matplotlib anaconda

我正在尝试使用matplotlib在python中绘制相同的值。最初我的代码运行良好,有图,但是现在它给了我以下错误

Traceback (most recent call last):
  File "remd_rmsd.py", line 35, in <module>
    ax.plot(data[0::100,0], data[0::100,1], fish, '-', label=fish)
  File "/home/rohit/anaconda3/lib/python3.6/site-packages/mpl_toolkits/mplot3d/axes3d.py", line 1567, in plot
    lines = super(Axes3D, self).plot(xs, ys, *args, **kwargs)
  File "/home/rohit/anaconda3/lib/python3.6/site-packages/matplotlib/__init__.py", line 1855, in inner
    return func(ax, *args, **kwargs)
  File "/home/rohit/anaconda3/lib/python3.6/site-packages/matplotlib/axes/_axes.py", line 1527, in plot
    for line in self._get_lines(*args, **kwargs):
  File "/home/rohit/anaconda3/lib/python3.6/site-packages/matplotlib/axes/_base.py", line 406, in _grab_next_args
    for seg in self._plot_args(this, kwargs):
  File "/home/rohit/anaconda3/lib/python3.6/site-packages/matplotlib/axes/_base.py", line 355, in _plot_args
    linestyle, marker, color = _process_plot_format(tup[-1])
  File "/home/rohit/anaconda3/lib/python3.6/site-packages/matplotlib/axes/_base.py", line 122, in _process_plot_format
    'Illegal format string "%s"; two color symbols' % fmt)
ValueError: Illegal format string "rmsd_job0.46"; two color symbols

摘要如下。 ax.plot中的fish被用作标签,并且是文件名。文件名是rmsd_job0.46。我知道为什么它是非法字符串。 下面是我用来获取的图。

initial plot

fig = plt.figure(num=None, figsize=(15, 10), dpi=120, facecolor='w', edgecolor='k')
ax = fig.add_subplot(111, projection='3d')

for f in filenames:
data = np.genfromtxt(fname=f, delimiter=' ')
#print(data[0::100,1])
if(np.average(data[::,1])>threshold):
    #print(data[0::100,1])
    f_w_ext = os.path.basename(f)
    fish, file_extension = os.path.splitext(f_w_ext)
    ax.plot(data[0::100,0], data[0::100,1], fish, '-', label=fish)
    noplot=1

0 个答案:

没有答案