0

Hye I was trying to use matplotlib for interpreting data using bargraph on centos 6.5 with python 2.6.6 With this code

#!/usr/bin/python
import matplotlib.pyplot as plt


x=[1,2,3]
y=[3,4,5]

plt.bar(x,y,label='Bars1')
plt.xlabel('x')
plt.ylabel('y')
plt.title("abc")
plt.legend()
plt.show()

I have made this script executable via chmod +x plothisto.py in terminal but when I run this using ./ plothisto.py it just executes and displays nothing..and ends in terminal itself can someone help me know the problem and reason and correction required.

3
  • I think that has to do the backend: you need to make sure that you use a graphical backend. See my answer. Commented Sep 9, 2017 at 15:25
  • I had run a similar program that used a matplotlib to draw a pie chart and that worked flawlessly don't know what is leading to the fault in this.. Commented Sep 9, 2017 at 15:32
  • I just tested your script on python3 with one of the latest matplotlib version and it works. Try to save the image with plt.savefig() instead of showing it. Commented Sep 9, 2017 at 15:36

0

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.