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.

Pranjal Gupta
  • 581
  • 7
  • 10
  • I think that has to do the backend: you need to make sure that you use a graphical backend. See [my answer](https://stackoverflow.com/a/14559772/1860757). – Francesco Montesano Sep 09 '17 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.. – Pranjal Gupta Sep 09 '17 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()``](https://matplotlib.org/api/pyplot_api.html?highlight=matplotlib%20pyplot%20savefig#matplotlib.pyplot.savefig) instead of showing it. – Francesco Montesano Sep 09 '17 at 15:36

0 Answers0