Show charts

I am trying to have PyCharm show my graphics, but when I run this script nothing appears on the screen.

from pylab import *

def main():
    ion()
    t = arange(0.0, 2.0, 0.01)
    s = sin(2*pi*t)
    plot(t, s)

    xlabel('time (s)')
    ylabel('voltage (mV)')
    title('About as simple as it gets, folks')
    grid(True)   
    show()
   
I am using Python 2.7.6, Pycharm 3.4 and Windows 7 x64.

---
D:\Python27\python.exe "D:/sletmig/python tests/pandas/chart.py"

Process finished with exit code 0
----

Warning: I am new to Python!
2 comments
Comment actions Permalink
Is what you posted the entirety of your code? If so, you're not actually calling the main() function.
0
Comment actions Permalink
To add to what Preston said, if you are just executing this .py file, you run it like:

Code
if __name__ == "__main__":
    main()
prettyPrint();


and have it not indented. This bit of code only gets run if the file is run on itself, and not if it's imported from something else, as Python doesn't look for a main function like other languages.
0

Please sign in to leave a comment.