I have a file containing 2 columns like:
111, 3
122, 4
155, 3
192, 5
11, 9
123, 10
120, 23
How can I be able to write the data like ((111,122,155,192,11,123,120),(3,4,3,5,9,10,23)) . Now all I want to do is to plot it in a histogram using matplotlib
.
please help with some basic ideas. !
Do you mean something like this?
>>> import numpy as np
>>> import matplotlib.pyplot as plt
>>> xs, ys = np.loadtxt('/tmp/example.txt', delimiter=',').T
>>> print xs
[ 111. 122. 155. 192. 11. 122. 120.]
>>> print ys
[ 3. 4. 3. 5. 9. 10. 23.]
>>> plt.bar(xs, ys)
<Container object of 7 artists>
>>> plt.show()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.