[Matplotlib-users] How to Turn Off Blocking by Method show()
I have a Python program which calls matplotlib's show() method to display a plot, but control does not return to my program until I close the displayed figure. I want control to immediately return to my program so that I can display additional figures as well. The doco (matplotlib 1.1.1) for the show() method mentions an experimental key word arg named 'block', that can be set to True or False. This looks promising, but plt.show(block = False) raises type error "got an unexpected keyword argument 'block'". A call to plt.show() works fine. The method appears to accept no arguments. Can anyone suggest how to bypass the blocking behaviour of the show() method? TIA, Jon -- View this message in context: http://old.nabble.com/How-to-Turn-Off-Blocking-by-Method-show%28%29-tp34188043p34188043.html Sent from the matplotlib - users mailing list archive at Nabble.com. -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] How to Turn Off Blocking by Method show()
Solved - just discovered methods ion() and ioff() which do the job. JonBL wrote: > > I have a Python program which calls matplotlib's show() method to display > a plot, but control does not return to my program until I close the > displayed figure. I want control to immediately return to my program so > that I can display additional figures as well. > > The doco (matplotlib 1.1.1) for the show() method mentions an experimental > key word arg named 'block', that can be set to True or False. This looks > promising, but plt.show(block = False) raises type error "got an > unexpected keyword argument 'block'". A call to plt.show() works fine. The > method appears to accept no arguments. > > Can anyone suggest how to bypass the blocking behaviour of the show() > method? > > TIA, > Jon > -- View this message in context: http://old.nabble.com/How-to-Turn-Off-Blocking-by-Method-show%28%29-tp34188043p34188078.html Sent from the matplotlib - users mailing list archive at Nabble.com. -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] How to Change Axis Tick Mark Labels
I have a line plot where the x-axis values are numbers, with displayed tick mark values of 0, 100, 200 ... 500 - a total of 6 tick marks. These values represent the number of days since a certain date. I have a function which converts a number such as 100, to date string '23-Jun-11', which I want to display as the x-axis label instead of 100. Following the pypib example xaxis_props.py, and printing dir(label) for each label in the x-axis tick labels, I can see that a label object supports a number of methods that might assist in changing the text of tick mark labels. I was hoping to use the get_text() method to retrieve the label's text (eg, 100), transform this to a date string by my function, and then use the set_text() method to re-assign the displayed label. This approach does not work for me. The get_text() method returns a zero-length string (not None) for each label, and the set_text() method does not change the displayed tick mark values. But I can use the set_color() method to change the colour of displayed values as per example xaxis_props.py. Any suggestions on how to change the text of displayed x-axis tick marks? TIA, Jon -- View this message in context: http://old.nabble.com/How-to-Change-Axis-Tick-Mark-Labels-tp34195324p34195324.html Sent from the matplotlib - users mailing list archive at Nabble.com. -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] How to Change Axis Tick Mark Labels
Using FuncFormatter with my conversion procedure has solved my problem. I did not use the Python datetime module to generate the tickmark labels as some of your examples suggested. Instead, my conversion procedure pulls the required formatted date string for an x-axis ticklabel date serial number from an Oracle database which is the source of my plotted data. This approach has also answered another question I had in mind - how do I get the x= co-ordinate displayed at the bottom of the figure, to report the formatted date rather than its serial number. I also had a response from Phil Elson who suggested using using FuncFormatter as well. Many thanks to both of you for your timely responses to my query. Regards, Jon Benjamin Root-2 wrote: > > On Sat, Jul 21, 2012 at 10:27 PM, JonBL wrote: > >> >> I have a line plot where the x-axis values are numbers, with displayed >> tick >> mark values of 0, 100, 200 ... 500 - a total of 6 tick marks. These >> values >> represent the number of days since a certain date. I have a function >> which >> converts a number such as 100, to date string '23-Jun-11', which I want >> to >> display as the x-axis label instead of 100. >> >> Following the pypib example xaxis_props.py, and printing dir(label) for >> each >> label in the x-axis tick labels, I can see that a label object supports a >> number of methods that might assist in changing the text of tick mark >> labels. I was hoping to use the get_text() method to retrieve the label's >> text (eg, 100), transform this to a date string by my function, and then >> use >> the set_text() method to re-assign the displayed label. >> >> This approach does not work for me. The get_text() method returns a >> zero-length string (not None) for each label, and the set_text() method >> does >> not change the displayed tick mark values. But I can use the set_color() >> method to change the colour of displayed values as per example >> xaxis_props.py. >> >> Any suggestions on how to change the text of displayed x-axis tick marks? >> >> TIA, >> Jon >> > > Without example code, it would be difficult to determine what you are > doing > incorrectly. That being said, there is an easier solution. If you know > the start date, do the following: > > from datetime import datetime, timedelta > startdate = datetime.strptime(datestr, "%d-%m-%y) # you need to look up > the format character for named months. > > xdates = np.array([startdate + timedelta(days=i) for i in xrange(501)]) > y = np.random.random(xdates.shape) > > plt.plot(xdates, y)# This should work, but plot_date() definitely will > work. > > Matplotlib recognizes the python datetime object and should format it for > you. You can even control the formatting. See the following examples: > http://matplotlib.sourceforge.net/examples/pylab_examples/date_demo_convert.html?highlight=datetime%20codex > http://matplotlib.sourceforge.net/examples/pylab_examples/date_demo2.html?highlight=datetime%20codex > http://matplotlib.sourceforge.net/examples/api/date_demo.html?highlight=datetime%20codex > http://matplotlib.sourceforge.net/examples/pylab_examples/date_demo1.html?highlight=datetime%20codex > > > I hope this helps! > Ben Root > > -- > Live Security Virtual Conference > Exclusive live event will cover all the ways today's security and > threat landscape has changed and how IT managers can respond. Discussions > will include endpoint security, mobile security and the latest in malware > threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ > ___ > Matplotlib-users mailing list > Matplotlib-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > -- View this message in context: http://old.nabble.com/How-to-Change-Axis-Tick-Mark-Labels-tp34195324p34197999.html Sent from the matplotlib - users mailing list archive at Nabble.com. -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Role of numpy Method arange in Matplotlib
I'm unsure about the role of numpy method arange in Matplotlib plots. All Matplotlib examples I have seen call numpy's method arange, and pass the result as the first arg to Matplotlib's plot method. But the following works as expected: --- quote --- import matplotlib.pyplot as plt import numpy as np dom = [1, 3, 4, 5, 7] # Plot domain on x-axis in ascending order of values ran = [7, -2, 11, 5.8, 0] # Plot range on y-axis in 1-to-1 correspondence with domain items fig = plt.figure() ax = plt.subplot(111) ax.plot(dom, ran) plt.grid() plt.show() --- end quote --- I'm not calling numpy.arange(arg) here, but I see the expected plot of 5 co-ordinate points. When should I use numpy.arange(arg) instead of what I have done above? Something to do with the domain that I want to include in the plot? TIA, Jon -- View this message in context: http://old.nabble.com/Role-of-numpy-Method-arange-in-Matplotlib-tp34223354p34223354.html Sent from the matplotlib - users mailing list archive at Nabble.com. -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Exceptions on Some Demos
I've used Add/Remove Software to install python-matplotlib-0.98.5.2-2.fc10(i386) and python-matplotlib-tk-0.98.5.2-2.fc10(i386) on my fedora 10 box, plus 11 dependencies, including Tkinter. Some matplotlib examples, eg pylab_examples Examples/arctest.py works nicely, but many do not as presented. Example api Examples/barchart_demo raises the following traceback when executed as-is: [jon@einstein matplotlib-examples]$ ./barchart.py Traceback (most recent call last): File "./barchart.py", line 18, in error_kw=dict(elinewidth=6, ecolor='pink')) File "/usr/lib/python2.5/site-packages/matplotlib/pyplot.py", line 1656, in bar ret = gca().bar(*args, **kwargs) File "/usr/lib/python2.5/site-packages/matplotlib/axes.py", line 4075, in bar r.update(kwargs) File "/usr/lib/python2.5/site-packages/matplotlib/artist.py", line 548, in update raise AttributeError('Unknown property %s'%k) AttributeError: Unknown property error_kw (I've copied the example code into script barchart.py, and run it from there.) The problem line is: rects1 = plt.bar(ind, menMeans, width, color='r', yerr=menStd, error_kw=dict(elinewidth=6, ecolor='pink')) If I replace this with: rects1 = plt.bar(ind, menMeans, width, color='r', yerr=menStd) and do the same thing for the rects2 statement, the demonstration then presents the bar chart. The problem seems to lie somewhere with the error_kw arg being passed to method plt.bar. Is there something else I need to do to get the provided examples to work as coded? TIA, Jon -- View this message in context: http://old.nabble.com/Exceptions-on-Some-Demos-tp31977899p31977899.html Sent from the matplotlib - users mailing list archive at Nabble.com. -- All of the data generated in your IT infrastructure is seriously valuable. Why? It contains a definitive record of application performance, security threats, fraudulent activity, and more. Splunk takes this data and makes sense of it. IT sense. And common sense. http://p.sf.net/sfu/splunk-d2d-c2 ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Exceptions on Some Demos
Thanks, Ben. I'll install 1.0.1. I'm aware of the situation about Fedora 10. Regards, Jon Benjamin Root-2 wrote: > > On Fri, Jul 1, 2011 at 10:02 PM, JonBL wrote: > >> >> I've used Add/Remove Software to install >> python-matplotlib-0.98.5.2-2.fc10(i386) and >> python-matplotlib-tk-0.98.5.2-2.fc10(i386) on my fedora 10 box, plus 11 >> dependencies, including Tkinter. Some matplotlib examples, eg >> pylab_examples >> Examples/arctest.py works nicely, but many do not as presented. >> >> Example api Examples/barchart_demo raises the following traceback when >> executed as-is: >> >> [jon@einstein matplotlib-examples]$ ./barchart.py >> Traceback (most recent call last): >> File "./barchart.py", line 18, in >>error_kw=dict(elinewidth=6, ecolor='pink')) >> File "/usr/lib/python2.5/site-packages/matplotlib/pyplot.py", line 1656, >> in bar >>ret = gca().bar(*args, **kwargs) >> File "/usr/lib/python2.5/site-packages/matplotlib/axes.py", line 4075, >> in >> bar >>r.update(kwargs) >> File "/usr/lib/python2.5/site-packages/matplotlib/artist.py", line 548, >> in >> update >>raise AttributeError('Unknown property %s'%k) >> AttributeError: Unknown property error_kw >> >> (I've copied the example code into script barchart.py, and run it from >> there.) >> >> The problem line is: >> >> rects1 = plt.bar(ind, menMeans, width, >>color='r', >>yerr=menStd, >>error_kw=dict(elinewidth=6, ecolor='pink')) >> >> If I replace this with: >> >> rects1 = plt.bar(ind, menMeans, width, >>color='r', >>yerr=menStd) >> >> and do the same thing for the rects2 statement, the demonstration then >> presents the bar chart. >> >> The problem seems to lie somewhere with the error_kw arg being passed to >> method plt.bar. Is there something else I need to do to get the provided >> examples to work as coded? >> >> TIA, >> Jon >> > > Jon, > > The examples on the website are for version 1.0.1, which is a couple of > years older than version 0.98. Many examples utilizes new features that > have since been added to matplotlib. > > Also, as a side note, Fedora 10 has stopped receiving updates of any kind > about 2 years ago. This also means security updates. > > Ben Root > > -- > All of the data generated in your IT infrastructure is seriously valuable. > Why? It contains a definitive record of application performance, security > threats, fraudulent activity, and more. Splunk takes this data and makes > sense of it. IT sense. And common sense. > http://p.sf.net/sfu/splunk-d2d-c2 > ___ > Matplotlib-users mailing list > Matplotlib-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > -- View this message in context: http://old.nabble.com/Exceptions-on-Some-Demos-tp31977899p31981750.html Sent from the matplotlib - users mailing list archive at Nabble.com. -- All of the data generated in your IT infrastructure is seriously valuable. Why? It contains a definitive record of application performance, security threats, fraudulent activity, and more. Splunk takes this data and makes sense of it. IT sense. And common sense. http://p.sf.net/sfu/splunk-d2d-c2 ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users