Re: [Matplotlib-users] logarithmic plotting and the grid
I think he wants to turn the grid on for both major and minor ticks. I'm interested in that also. Is there a way to do that? Lee Jae-Joon Lee lee.j.j...@gmail.com 02/10/2010 08:10 PM To K L klu1...@gmail.com cc matplotlib-users@lists.sourceforge.net Subject Re: [Matplotlib-users] logarithmic plotting and the grid Caterpillar: Confidential Green Retain Until: 03/12/2010 grid takes an optional argument which. Unfortunately this is not properly documented with pylab.grid and Axes.grid. But see http://matplotlib.sourceforge.net/api/axis_api.html?highlight=grid#matplotlib.axis.Axis.grid grid(True) # this turns on gridlines for major ticks grid(True, which=minor) # this turns on gridlines for minor ticks. -JJ On Wed, Feb 10, 2010 at 6:18 PM, K L klu1...@gmail.com wrote: Hi, I want a more detailed grid for my logarithmic plotting. The following code: from pylab import * semilogy(range(10)) grid(True) show() will produce output like this: http://i49.tinypic.com/2dpd3r.png Notice that the grid uniformly slices the image. And some ticks on the y-axis doesn't have grid lines. This is not want I want. Conversely, something like this is preferred: http://www.mathworks.com/access/helpdesk/help/toolbox/comm/ug/bert_mat_explot1.gif Thanks! -- SOLARIS 10 is the OS for Data Centers - provides features such as DTrace, Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW http://p.sf.net/sfu/solaris-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- SOLARIS 10 is the OS for Data Centers - provides features such as DTrace, Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW http://p.sf.net/sfu/solaris-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- SOLARIS 10 is the OS for Data Centers - provides features such as DTrace, Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW http://p.sf.net/sfu/solaris-dev2dev___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Runtime Error - Need Advice
Thanks for all your suggestions Christoph. Launching the Tk Python Shell instead of PythonWin seems to work consistently - I get the correct plot figure and the correct log_plot.png file created everytime I run the script. I never did install Ipython, but I'll consider that for a future upgrade. Lee Christoph Gohlke cgoh...@uci.edu 02/09/2010 04:35 PM To matplotlib-users matplotlib-users@lists.sourceforge.net cc Subject Re: [Matplotlib-users] Runtime Error - Need Advice Caterpillar: Confidential Green Retain Until: 03/11/2010 I can now reproduce this. It seems the same old problem that PythonWin can not reliably run matplotlib because successive runs of the script use the same interpreter. Ipython should work. Append pylab.close() to your script; at least it will not crash on the second run. -- Christoph On 2/9/2010 10:44 AM, Lee Boger wrote: Although, if I close the figure then re-run the script, a new figure pops up but it doesn't have any data plotted. Interpreter is now locked up. I'm still not fixing it completely. There is also no figure stored as a file log_plot. Lee *Christoph Gohlke cgoh...@uci.edu* 02/09/2010 01:23 PM To Lee Boger boger_...@cat.com cc Subject Re: [Matplotlib-users] Runtime Error - Need Advice Caterpillar: Confidential GreenRetain Until: 03/11/2010 Change the last line to pylab.show() and it should work. Anyway, this example should not crash the interpreter. I can reproduce the crash on Python 2.4, 2.5, and 2.6 (32 and 64 bit) on Windows with mpl 0.99.1 but not on Ubuntu 9.1 with mpl 0.99.0. The shortest example that crashes is: python -c import pylab;pylab.subplot(111).figure.show() or on the interactive prompt: import pylab pylab.subplot(111).figure.show() exit() Fatal Python error: PyEval_RestoreThread: NULL tstate This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information. -- Christoph On 2/9/2010 7:57 AM, Lee Boger wrote: Windows XP Professional with Python 2.5 installed (pywin32 build 210) - came with dSPACE software package Downloaded and installed matplotlib-0.99.1.win32-py2.5.exe from sourceforge.net Downloaded and installed numpy-1.4.0-win32-superpack-python2.5.exe from sourceforge.net Executing the following simple log plot script within PythonWin: *from* matplotlib *import* pylab # Create some artificial data. test_frequency = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20] test_results = [-0.2, -0.7, -1.0, -1.5, -2.0, -2.5, -3.0, -3.5, -4, -5, -6, -7.1, -8, -9, -10, -11, -12, -15, -20, -25] spec_frequency = [6, 8] spec_results = [-3.0, -3.0] # Plot figure = pylab.subplot(111) figure.semilogx() figure.scatter(test_frequency, test_results, s=20, c='b', marker='s', edgecolors='none') figure.scatter(spec_frequency, spec_results, s=40, c='g', marker='s', edgecolors='none') figure.grid(True) figure.set_xlabel(rFrequency (Hz), fontsize = 12) figure.set_ylabel(rActuator Response (db), fontsize = 12) figure.figure.savefig('log_plot') figure.figure.show() Plots a figure on the screen that looks correct, then the following error (when I click OK, PythonWin closes) Any advice would be appreciated. Maybe it's an installation or setup issue, but I'm pretty knew to Python programming and don't know how to debug this. Lee Boger -- The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from experience hosting pros just a phone call away. http://p.sf.net/sfu/theplanet-com ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- SOLARIS 10 is the OS for Data Centers - provides features such as DTrace, Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW http://p.sf.net/sfu/solaris-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- SOLARIS 10 is the OS for Data Centers - provides features such as DTrace, Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW http://p.sf.net/sfu/solaris-dev2dev___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Runtime Error - Need Advice
Thanks for your help. I'll look into ipython. Lee Eric Firing efir...@hawaii.edu 02/09/2010 02:31 PM To Lee Boger boger_...@cat.com, matplotlib-users matplotlib-users@lists.sourceforge.net cc Subject Re: [Matplotlib-users] Runtime Error - Need Advice Caterpillar: Confidential Green Retain Until: 03/11/2010 Lee Boger wrote: Thanks for the quick feedback. I changed the last line from figure.figure.show() to pyplot.show() and it worked without crashing the interpreter. However, if I close the figure then re-run the script, a new figure pops up but it doesn't have any data plotted. Interpreter is now locked up, the run-time error occurred and no figure stored as a file log_plot. I un-installed numpy-1.4.0 and installed numpy-1.3.0, but the results were as I just described. Lee At this point a Windows user may need to step in. I know nothing about PythonWin. My suspicion is that this is a problem of dueling event loops, and one solution would be to use ipython instead of pythonwin. (Note that you typically need to use reply to all on this list, otherwise the reply does not get copied to the list.) Eric *Eric Firing efir...@hawaii.edu* 02/09/2010 01:35 PM To Lee Boger boger_...@cat.com cc matplotlib-users@lists.sourceforge.net Subject Re: [Matplotlib-users] Runtime Error - Need Advice Caterpillar: Confidential GreenRetain Until: 03/11/2010 Lee Boger wrote: Windows XP Professional with Python 2.5 installed (pywin32 build 210) - came with dSPACE software package Downloaded and installed matplotlib-0.99.1.win32-py2.5.exe from sourceforge.net Downloaded and installed numpy-1.4.0-win32-superpack-python2.5.exe from sourceforge.net I suspect this is the problem: numpy-1.4.0 is considered broken and has been withdrawn. Specifically, it introduces binary incompatibility with programs compiled against prior versions of numpy, including matplotlib. If you go back to the numpy sourceforge site now, I think you will see an earlier version that you can install in place of 1.4.0 (after removing the latter). Eric Executing the following simple log plot script within PythonWin: *from* matplotlib *import* pylab # Create some artificial data. test_frequency = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20] test_results = [-0.2, -0.7, -1.0, -1.5, -2.0, -2.5, -3.0, -3.5, -4, -5, -6, -7.1, -8, -9, -10, -11, -12, -15, -20, -25] spec_frequency = [6, 8] spec_results = [-3.0, -3.0] # Plot figure = pylab.subplot(111) figure.semilogx() figure.scatter(test_frequency, test_results, s=20, c='b', marker='s', edgecolors='none') figure.scatter(spec_frequency, spec_results, s=40, c='g', marker='s', edgecolors='none') figure.grid(True) figure.set_xlabel(rFrequency (Hz), fontsize = 12) figure.set_ylabel(rActuator Response (db), fontsize = 12) figure.figure.savefig('log_plot') figure.figure.show() Plots a figure on the screen that looks correct, then the following error (when I click OK, PythonWin closes) Any advice would be appreciated. Maybe it's an installation or setup issue, but I'm pretty knew to Python programming and don't know how to debug this. Lee Boger -- SOLARIS 10 is the OS for Data Centers - provides features such as DTrace, Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW http://p.sf.net/sfu/solaris-dev2dev___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Runtime Error - Need Advice
I tried something that seems to work consistently - I get the correct plot figure and the correct log_plot.png file created everytime I run the script. From the Start menu, I chose All Programs-Python2.5-IDLE (Python GUI) instead of All Programs-Python2.5-PythonWin, which creates the Tk Python Shell. I then open the script file and run it. I think you were right. Does this make sense? Lee __ Thanks for your help. I'll look into ipython. Lee Eric Firing efir...@hawaii.edu 02/09/2010 02:31 PM To Lee Boger boger_...@cat.com, matplotlib-users matplotlib-users@lists.sourceforge.net cc Subject Re: [Matplotlib-users] Runtime Error - Need Advice Caterpillar: Confidential Green Retain Until: 03/11/2010 Lee Boger wrote: Thanks for the quick feedback. I changed the last line from figure.figure.show() to pyplot.show() and it worked without crashing the interpreter. However, if I close the figure then re-run the script, a new figure pops up but it doesn't have any data plotted. Interpreter is now locked up, the run-time error occurred and no figure stored as a file log_plot. I un-installed numpy-1.4.0 and installed numpy-1.3.0, but the results were as I just described. Lee At this point a Windows user may need to step in. I know nothing about PythonWin. My suspicion is that this is a problem of dueling event loops, and one solution would be to use ipython instead of pythonwin. (Note that you typically need to use reply to all on this list, otherwise the reply does not get copied to the list.) Eric *Eric Firing efir...@hawaii.edu* 02/09/2010 01:35 PM To Lee Boger boger_...@cat.com cc matplotlib-users@lists.sourceforge.net Subject Re: [Matplotlib-users] Runtime Error - Need Advice Caterpillar: Confidential GreenRetain Until: 03/11/2010 Lee Boger wrote: Windows XP Professional with Python 2.5 installed (pywin32 build 210) - came with dSPACE software package Downloaded and installed matplotlib-0.99.1.win32-py2.5.exe from sourceforge.net Downloaded and installed numpy-1.4.0-win32-superpack-python2.5.exe from sourceforge.net I suspect this is the problem: numpy-1.4.0 is considered broken and has been withdrawn. Specifically, it introduces binary incompatibility with programs compiled against prior versions of numpy, including matplotlib. If you go back to the numpy sourceforge site now, I think you will see an earlier version that you can install in place of 1.4.0 (after removing the latter). Eric Executing the following simple log plot script within PythonWin: *from* matplotlib *import* pylab # Create some artificial data. test_frequency = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20] test_results = [-0.2, -0.7, -1.0, -1.5, -2.0, -2.5, -3.0, -3.5, -4, -5, -6, -7.1, -8, -9, -10, -11, -12, -15, -20, -25] spec_frequency = [6, 8] spec_results = [-3.0, -3.0] # Plot figure = pylab.subplot(111) figure.semilogx() figure.scatter(test_frequency, test_results, s=20, c='b', marker='s', edgecolors='none') figure.scatter(spec_frequency, spec_results, s=40, c='g', marker='s', edgecolors='none') figure.grid(True) figure.set_xlabel(rFrequency (Hz), fontsize = 12) figure.set_ylabel(rActuator Response (db), fontsize = 12) figure.figure.savefig('log_plot') figure.figure.show() Plots a figure on the screen that looks correct, then the following error (when I click OK, PythonWin closes) Any advice would be appreciated. Maybe it's an installation or setup issue, but I'm pretty knew to Python programming and don't know how to debug this. Lee Boger -- SOLARIS 10 is the OS for Data Centers - provides features such as DTrace, Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW http://p.sf.net/sfu/solaris-dev2dev___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Runtime Error - Need Advice
Python version 2.5.1, Tk version 8.4, IDLE version 1.2.1 Lee Christoph Gohlke cgoh...@uci.edu 02/09/2010 03:08 PM To matplotlib-users matplotlib-users@lists.sourceforge.net cc Subject Re: [Matplotlib-users] Runtime Error - Need Advice Caterpillar: Confidential Green Retain Until: 03/11/2010 I am not sure what's going on. The script you posted imports pylab in the first line. It should be defined. The scrit works just fine after the proposed changes, even from Pythonwin. Did you completely quit Pythonwin after the crashes and made sure no corrupted python instance was left running? Please send the version string of your python installation. Christoph On 2/9/2010 11:10 AM, Lee Boger wrote: Per another suggestion, I did uninstall numpy 1.4 and installed numpy 1.3, but got the same results. Using pylab.savefig('log_plot) resulted in the following error: Traceback (most recent call last): File C:\Program Files\Common Files\dSPACE\Python25\lib\site-packages\Pythonwin\pywin\framework\scriptutils.py, line 310, in RunScript exec codeObject in __main__.__dict__ File C:\Documents and Settings\BogerLC\My Documents\Script2.py, line 20, in module pylab.savefig('log_plot') NameError: name 'pylab' is not defined Using pyplot.savefig('log_plot') does not have an error, but I still get no file saved. Maybe it is a backend thing, which I know nothing about. I'll look into it. Thanks. Lee *Christoph Gohlke cgoh...@uci.edu* 02/09/2010 02:03 PM To matplotlib-users matplotlib-users@lists.sourceforge.net cc Subject Re: [Matplotlib-users] Runtime Error - Need Advice Caterpillar: Confidential GreenRetain Until: 03/11/2010 Use pylab.savefig('log_plot'). Also saving the figure to file and showing it interactively in the same script might involve switching backends, which might not work as expected. It is advisable to downgrade to numpy 1.3. -- Christoph On 2/9/2010 10:44 AM, Lee Boger wrote: Although, if I close the figure then re-run the script, a new figure pops up but it doesn't have any data plotted. Interpreter is now locked up. I'm still not fixing it completely. There is also no figure stored as a file log_plot. Lee *Christoph Gohlke cgoh...@uci.edu* 02/09/2010 01:23 PM To Lee Boger boger_...@cat.com cc Subject Re: [Matplotlib-users] Runtime Error - Need Advice Caterpillar: Confidential GreenRetain Until: 03/11/2010 Change the last line to pylab.show() and it should work. Anyway, this example should not crash the interpreter. I can reproduce the crash on Python 2.4, 2.5, and 2.6 (32 and 64 bit) on Windows with mpl 0.99.1 but not on Ubuntu 9.1 with mpl 0.99.0. The shortest example that crashes is: python -c import pylab;pylab.subplot(111).figure.show() or on the interactive prompt: import pylab pylab.subplot(111).figure.show() exit() Fatal Python error: PyEval_RestoreThread: NULL tstate This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information. -- Christoph On 2/9/2010 7:57 AM, Lee Boger wrote: Windows XP Professional with Python 2.5 installed (pywin32 build 210) - came with dSPACE software package Downloaded and installed matplotlib-0.99.1.win32-py2.5.exe from sourceforge.net Downloaded and installed numpy-1.4.0-win32-superpack-python2.5.exe from sourceforge.net Executing the following simple log plot script within PythonWin: *from* matplotlib *import* pylab # Create some artificial data. test_frequency = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20] test_results = [-0.2, -0.7, -1.0, -1.5, -2.0, -2.5, -3.0, -3.5, -4, -5, -6, -7.1, -8, -9, -10, -11, -12, -15, -20, -25] spec_frequency = [6, 8] spec_results = [-3.0, -3.0] # Plot figure = pylab.subplot(111) figure.semilogx() figure.scatter(test_frequency, test_results, s=20, c='b', marker='s', edgecolors='none') figure.scatter(spec_frequency, spec_results, s=40, c='g', marker='s', edgecolors='none') figure.grid(True) figure.set_xlabel(rFrequency (Hz), fontsize = 12) figure.set_ylabel(rActuator Response (db), fontsize = 12) figure.figure.savefig('log_plot') figure.figure.show() Plots a figure on the screen that looks correct, then the following error (when I click OK, PythonWin closes) Any advice would be appreciated. Maybe it's an installation or setup issue, but I'm pretty knew to Python programming and don't know how to debug this. Lee Boger -- The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from