I am running Mac OS X 10.8.4 and Python 2.7.
I just wanted to make a scatter plot graph in python. It runs completely fine until I begin to put in the lines about graph. So when I include window = plt.figure().
Here is my code:
import csv
import numpy as np
import matplotlib.pyplot as plt
# this program will graph things on a scatter plot
def scatter(filename):
flux_array =[]
ratio_array = []
with open(filename, "U") as csvfile:
reader = csv.reader(csvfile, delimiter = ',', quoting = csv.QUOTE_NONNUMERIC)
for row in reader:
flux_array.append(row[0])
ratio_array.append(row[1])
window = plt.figure()
plot = window.add_subplot(111, autoscale_on = True) #sets up plot in figure\
plot.set_title("H-aplha vs. H-alpha/H-beta")
plot.set_xlabel("H-aplha")
plot.set_ylabel("ratio")
plot.scatter(flux_array,ratio_array, 10, "b")
window.show()
if __name__ == "__main__":
scatter('/Users/Emily/Documents/MMO_2013/Graphs/sample.csv')
Here is the error I get: (sorry it is really long) A new window pops up and that has the headline "Python has quit unexpectedly" And in the rest of the window it says:
Process: Python [23039]
Path: /Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
Identifier: org.python.python
Version: 2.7.0 (2.7.0)
Code Type: X86 (Native)
Parent Process: Python [23034]
User ID: 501
Date/Time: 2013-06-20 16:44:34.145 -0400
OS Version: Mac OS X 10.8.4 (12E55)
Report Version: 10
Interval Since Last Report: 14896 sec
Crashes Since Last Report: 6
Per-App Interval Since Last Report: 26 sec
Per-App Crashes Since Last Report: 6
Anonymous UUID: 9498690C-E00D-5F98-DA9B-09FF275B2770
Crashed Thread: 0 Dispatch queue: com.apple.main-thread
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Application Specific Information:
abort() called
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 libsystem_kernel.dylib 0x96e0ea6a __pthread_kill + 10
1 libsystem_c.dylib 0x95a9cb2f pthread_kill + 101
2 libsystem_c.dylib 0x95ad34ec abort + 168
3 Tcl 0x02a9cd93 Tcl_PanicVA + 229
4 Tcl 0x02a9cdae Tcl_Panic + 27
5 Tcl 0x02a7324d 0x2a20000 + 340557
6 Tcl 0x02a68626 TclStackAlloc + 60
7 Tcl 0x02a94ddf TclResetShadowedCmdRefs + 31
8 Tcl 0x02a2c35b Tcl_CreateCommand + 432
9 _tkagg.so 0x029f27e0 _tkinit(_object*, _object*) + 112
10 org.python.python 0x000ca3e0 PyEval_EvalFrameEx + 20720
11 org.python.python 0x000cc4ba PyEval_EvalCodeEx + 2042
12 org.python.python 0x000ca471 PyEval_EvalFrameEx + 20865
13 org.python.python 0x000cc4ba PyEval_EvalCodeEx + 2042
14 org.python.python 0x000ca471 PyEval_EvalFrameEx + 20865
15 org.python.python 0x000cc4ba PyEval_EvalCodeEx + 2042
16 org.python.python 0x00041ca2 function_call + 162
17 org.python.python 0x0000f375 PyObject_Call + 85
18 org.python.python 0x000c7d5b PyEval_EvalFrameEx + 10859
19 org.python.python 0x000cc4ba PyEval_EvalCodeEx + 2042
20 org.python.python 0x00041ca2 function_call + 162
21 org.python.python 0x0000f375 PyObject_Call + 85
22 org.python.python 0x00021c66 instancemethod_call + 422
23 org.python.python 0x0000f375 PyObject_Call + 85
24 org.python.python 0x000c435e PyEval_CallObjectWithKeywords + 78
25 _tkinter.so 0x00722ccc PythonCmd + 220
26 Tcl 0x00737377 TclInvokeStringCommand + 135
27 Tcl 0x00738fc8 TclEvalObjvInternal + 678
28 Tcl 0x0075e4e5 TclExecuteByteCode + 2050
29 Tcl 0x0075dc49 Tcl_ExprObj + 1115
30 Tcl 0x0073b3fa Tcl_ExprBooleanObj + 40
31 Tcl 0x007418ba Tcl_IfObjCmd + 210
32 Tcl 0x00738fc8 TclEvalObjvInternal + 678
33 Tcl 0x0073a061 EvalEx + 926
34 Tcl 0x00739cbe Tcl_EvalEx + 50
35 Tk 0x01006b83 Tk_BindEvent + 4036
36 Tk 0x0100b2ea TkBindEventProc + 295
37 Tk 0x01012460 Tk_HandleEvent + 1277
38 Tk 0x0102ab46 TkDoConfigureNotify + 114
39 Tk 0x0102a9c5 Tk_MakeWindowExist + 331
40 Tk 0x0102aa63 Tk_MapWindow + 34
41 Tk 0x0102379b ArrangePacking + 1750
42 Tcl 0x00791309 TclServiceIdle + 61
43 Tcl 0x0078086d Tcl_DoOneEvent + 337
44 Tk 0x0100c5e0 Tk_UpdateObjCmd + 135
45 Tcl 0x00738fc8 TclEvalObjvInternal + 678
46 Tcl 0x007392fd Tcl_EvalObjv + 118
47 _tkinter.so 0x00724738 Tkapp_Call + 216
48 org.python.python 0x000ca3e0 PyEval_EvalFrameEx + 20720
49 org.python.python 0x000cbc88 PyEval_EvalFrameEx + 27032
50 org.python.python 0x000cc4ba PyEval_EvalCodeEx + 2042
51 org.python.python 0x000ca471 PyEval_EvalFrameEx + 20865
52 org.python.python 0x000cc4ba PyEval_EvalCodeEx + 2042
53 org.python.python 0x000ca471 PyEval_EvalFrameEx + 20865
54 org.python.python 0x000cbc88 PyEval_EvalFrameEx + 27032
55 org.python.python 0x000cc4ba PyEval_EvalCodeEx + 2042
56 org.python.python 0x000caefa PyEval_EvalFrameEx + 23562
57 org.python.python 0x000cc4ba PyEval_EvalCodeEx + 2042
58 org.python.python 0x00041ca2 function_call + 162
59 org.python.python 0x0000f375 PyObject_Call + 85
60 org.python.python 0x000c7d5b PyEval_EvalFrameEx + 10859
61 org.python.python 0x000cc4ba PyEval_EvalCodeEx + 2042
62 org.python.python 0x000ca471 PyEval_EvalFrameEx + 20865
63 org.python.python 0x000cc4ba PyEval_EvalCodeEx + 2042
64 org.python.python 0x000cc647 PyEval_EvalCode + 87
65 org.python.python 0x000f24bf PyRun_StringFlags + 287
66 org.python.python 0x000f25be PyRun_SimpleStringFlags + 78
67 org.python.python 0x00109db8 Py_Main + 1512
68 org.python.python 0x00001f82 0x1000 + 3970
69 org.python.python 0x00001ea9 0x1000 + 3753
Threads 1-6 ...
Thread 0 crashed with X86 Thread State (32-bit):
eax: 0x00000000 ebx: 0x02ad639d ecx: 0xbfffba8c edx: 0x96e0ea6a
edi: 0xac6efa28 esi: 0x00000006 ebp: 0xbfffbaa8 esp: 0xbfffba8c
ss: 0x00000023 efl: 0x00000206 eip: 0x96e0ea6a cs: 0x0000000b
ds: 0x00000023 es: 0x00000023 fs: 0x00000000 gs: 0x0000000f
cr2: 0x02ad639d
Logical CPU: 0
Binary Images:
0x1000 - 0x1ff5 +org.python.python (2.7.0 - 2.7.0) <E493A842-C949-A532-656D-BC10750CCB80> /Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
0x5000 - 0x142fe3 +org.python.python (2.7.0, [c] 2004-2008 Python Software Foundation. - 2.7.0) <2815ECAD-BE96-97DE-C757-303EB571862B> /Library/Frameworks/Python.framework/Versions/2.7/Python
0x2d6000 - 0x2d7fff +time.so (???) <36AF5C9C-9495-3868-8A5A-4706C959F102>
a lot more lines like this...
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_locale.so
0x1554000 - 0x1556ff5 +_csv.so (???) <A4454B5F-D112-B662-F4A5-9B2E3C630DD2> /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_csv.so
0x161c000 - 0x16bdff9 multiarray.so (27.4) <3A9DA8B8-2C58-3FB0-B491-968A52101BA4> /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/core/multiarray.so
0x16d1000 - 0x1708ffe umath.so (27.4) <F31C1D02-F34A-36F5-847C-16CB5DC6610A> /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/core/umath.so
0x1714000 - 0x1725ff7 _sort.so (27.4) <36D7E10C-CC33-3A4A-9717-29F165644354> /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/core/_sort.so
0x176a000 - 0x176efff _dotblas.so (27.4) <C457183A-71CF-39AF-BEDD-8874CB2D190C> /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/core/_dotblas.so
0x1772000 - 0x178cff0 scalarmath.so (27.4) <078B9F29-CD28-3635-BCBC-4CFC6B392BEA> /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/core/scalarmath.so
0x1791000 - 0x1791ff5 +_weakref.so (???) <CC5A6874-5A1A-4431-FB8B-3CA18F0DDE5D>
more lines like this...
0x2e22000 - 0x2e23ffd com.apple.ironwoodcore (1.1.1 - 1.1.1) <098CE576-3239-3B41-9141-A5BE6E476C84> /System/Library/PrivateFrameworks/SpeechObjects.framework/Versions/A/Frameworks/DictationServicesCore.framework/DictationServicesCore
0x8fe75000 - 0x8fea7e57 dyld (210.2.3) <23516BE4-29BE-350C-91C9-F36E7999F0F1> /usr/lib/dyld
0x90007000 - 0x9000ffff libcopyfile.dylib (89) <4963541B-0254-371B-B29A-B6806888949B> /usr/lib/system/libcopyfile.dylib
a lot more lines like this...
/System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libvDSP.dylib
External Modification Summary:
Calls made by other processes targeting this process:
task_for_pid: 2
thread_create: 0
thread_set_state: 0
Calls made by this process:
task_for_pid: 0
thread_create: 0
thread_set_state: 0
Calls made by all processes on this machine:
task_for_pid: 818
thread_create: 1
thread_set_state: 0
Model: MacBookPro7,1, BootROM MBP71.0039.B0E, 2 processors, Intel Core 2 Duo, 2.4 GHz, 4 GB, SMC 1.62f7
Graphics: NVIDIA GeForce 320M, NVIDIA GeForce 320M, PCI, 256 MB
Memory Module: BANK 0/DIMM0, 2 GB, DDR3, 1067 MHz, 0x80CE, 0x4D34373142353637334648302D4346382020
Memory Module: BANK 1/DIMM0, 2 GB, DDR3, 1067 MHz, 0x80CE, 0x4D34373142353637334648302D4346382020
AirPort: spairport_wireless_card_type_airport_extreme (0x14E4, 0x8D), Broadcom BCM43xx 1.0 (5.106.98.100.17)
I have googled this quite a bit, but there aren't any answers really.
Thanks!
I think that your computer is crashing as the main thread is causing problems. Check if your Python is corrupt or that your graphics and system components are working well.
This was a problem with IDLE not knowing how to handle the windows created by matplotlib. What I needed to do was go to the terminal and do:
ipython -pylab
In [1]: run file.py
And that fixed it. Ipython knows how to deal with the interactivity with the graphs.
User contributions licensed under CC BY-SA 3.0