0

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. !

1 Answer 1

5

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()

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.