0

Suppose I have a table of data-

No. 200 400 600 800

1    13 14 17 18 

2    16 18 20 21

3    20 15 18 19

and so on...

where each column represents a y-value for a given x-value. The first line is the x-value and the first column is the number of each dataset.

How can I read in and plot each row seperately?

For an idea of how I would like my results to be for the table I have quoted above see the following images. I have plotted each plot individually.

http://postimg.org/image/yw46zw7er/92d01c08/

http://postimg.org/image/c1kf2nqwp/29a8b1c8/

4

1 回答 1

0

Matplotlib 通过绘制每一列来绘制二维数组,所以在这里你只需要转置你的数据。假设数据在一个名为data.csv.

import numpy as np
import matplotlib.pyplot as plt
data = np.loadtxt('data.csv')
x = [200, 400, 600, 800]
plt.plot(x, data.T)
plt.legend((1,2,3))
plt.show()

请求的情节

于 2013-05-19T15:37:49.773 回答