I'm trying to make an example bar graph using matplotlib. This is the script:
"""
====================
Horizontal bar chart
====================
This example showcases a simple horizontal bar chart.
"""
import matplotlib.pyplot as plt
plt.rcdefaults()
import numpy as np
import matplotlib.pyplot as plt
plt.rcdefaults()
fig, ax = plt.subplots()
# Example data
people = ('Tom', 'Dick', 'Harry', 'Slim', 'Jim')
y_pos = np.arange(len(people))
performance = 3 + 10 * np.random.rand(len(people))
error = np.random.rand(len(people))
ax.barh(y_pos, performance, xerr=error, align='center',
color='green', ecolor='black')
ax.set_yticks(y_pos)
ax.set_yticklabels(people)
ax.invert_yaxis() # labels read top-to-bottom
ax.set_xlabel('Performance')
ax.set_title('How fast do you want to go today?')
plt.show()
When I enter the code directly into the terminal it works, but when I try to call the script, I get this error:
Traceback (most recent call last):
File "bargraph.py", line 2, in <module>
import numpy as np
File "/Users/MattBell/Desktop/numpy.py", line 2, in <module>
import matplotlib.pyplot as plt
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/__init__.py", line 156, in <module>
from matplotlib.cbook import is_string_like
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/cbook.py", line 29, in <module>
import numpy.ma as ma
ImportError: No module named ma
I'm using OS X 10.10 and running python 2.7.