如何在单行中绘制多色?

时间:2018-07-17 15:50:34

标签: python python-3.x matplotlib plot simulation

我正在阅读一个文本文件,我想绘制这些列(y和z),但是如果x列的值是'out',则6点和4点的颜色应该是红色。按照这种逻辑,图中有6个点,但是4个点应该是蓝色,其他两个颜色应该是红色。有两个图,每个pragh有3点。我怎样才能做到这一点?

#-------input.dat---------
#   x          y     z
# col 1      col 2  col 3
# res          5      5
# out          6      4
# res          7      3
import matplotlib.pyplot as plt
import numpy as np
data[] =[]
with open('input.dat', skip_header=2,'r') as f:
     lines = f.readlines()
     for line in lines[2:]:
         data.append(list(line.split()))

y = (data[:, 2])
z = (data[:, 3])

------------------------
plt.plot(float(line[1]),b+)
for  line in enumerate(data)
   if line[0] == 'OUT'
        plt.plot(float(line[1]),r+)
-----------------------
plt.subplot(211)
plt.plot(y, 'b+', label=" Y figure ")
plt.subplot(212)
plt.plot(z, 'b+', label=" Z figure ")
plt.show()

0 个答案:

没有答案
相关问题