Re: [Matplotlib-users] moving marker line under mouse
Hi, For anyone still interested in this topic: I implemented a provisional solution myself, but it turned out that there is indeed already an example for a marker/cursor in the matplotlib documentation. It can be found at http://matplotlib.sourceforge.net/examples/pylab_examples/cursor_demo.html Cheers, Sven -- Cloud Computing - Latest Buzzword or a Glimpse of the Future? This paper surveys cloud computing today: What are the benefits? Why are businesses embracing it? What are its payoffs and pitfalls? http://www.accelacomm.com/jaw/sdnl/114/51425149/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] contourf: matplotlib.path.Path are LINETOs?
On 12/13/2011 11:03 AM, Nico Schlömer wrote: > Hi all, > > when drawing contourf plots, I inspected the underlying > matplotlib.path.Path elements that determine the curves and noticed > that they are all of code LINETO (see > http://matplotlib.sourceforge.net/api/path_api.html#matplotlib.path.Path) > although the number of vertices is 6, actually suggesting a CURVE4. > > Would that be a bug? I don't see it. x = np.arange(9) x.shape = (3,3) cs = contourf(x, 1) print cs.collections.get_paths() This shows a set of vertices with a matching set of LINETO (after an initial MOVETO). contour and contourf generate piece-wise linear paths with vertices on grid cell boundaries; they make no attempt to smooth out the contours. Eric > > Cheers, > Nico -- Systems Optimization Self Assessment Improve efficiency and utilization of IT resources. Drive out cost and improve service delivery. Take 5 minutes to use this Systems Optimization Self Assessment. http://www.accelacomm.com/jaw/sdnl/114/51450054/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] get_facecolor() returns 4-tuple, contains RGB values?
On Tue, Dec 13, 2011 at 3:55 PM, Nico Schlömer wrote: > > "RGB and RGBA are sequences of, respectively, 3 or 4 floats in the range > 0-1." > > That would explain it. It also seems that I never ever will have to > worry about CMYK values as they don't seem to be used anywhere in > matplotlib as a search on the website for "cmyk" suggests. > > --Nico > > Correct. Matplotlib currently does not support CMYK representation. The fourth element is the alpha (transparency) value. Ben Root -- Systems Optimization Self Assessment Improve efficiency and utilization of IT resources. Drive out cost and improve service delivery. Take 5 minutes to use this Systems Optimization Self Assessment. http://www.accelacomm.com/jaw/sdnl/114/51450054/___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] get_facecolor() returns 4-tuple, contains RGB values?
> "RGB and RGBA are sequences of, respectively, 3 or 4 floats in the range 0-1." That would explain it. It also seems that I never ever will have to worry about CMYK values as they don't seem to be used anywhere in matplotlib as a search on the website for "cmyk" suggests. --Nico On Tue, Dec 13, 2011 at 10:19 PM, Vlastimil Brom wrote: > 2011/12/13 Nico Schlömer : >> Hi, >> >> upon extracting the face color of a matplotlib.path.Path object, >> >> fc = obj.get_facecolor() >> >> I always seem to get an array of length 4. This initially led me to >> believe I'm dealing with CMYK values, but it really seems like the >> last entry is *always* 1.0 and the first three give the RGB >> representation of the respective color. >> Is there any documentation on color codes usage in matplotlib? >> >> Cheers, >> Nico >>... > > Hi, > maybe: > http://matplotlib.sourceforge.net/api/colors_api.html#module-matplotlib.colors > > "RGB and RGBA are sequences of, respectively, 3 or 4 floats in the range 0-1." > > hth, > vbr > > -- > Systems Optimization Self Assessment > Improve efficiency and utilization of IT resources. Drive out cost and > improve service delivery. Take 5 minutes to use this Systems Optimization > Self Assessment. http://www.accelacomm.com/jaw/sdnl/114/51450054/ > ___ > Matplotlib-users mailing list > Matplotlib-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Systems Optimization Self Assessment Improve efficiency and utilization of IT resources. Drive out cost and improve service delivery. Take 5 minutes to use this Systems Optimization Self Assessment. http://www.accelacomm.com/jaw/sdnl/114/51450054/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] get_facecolor() returns 4-tuple, contains RGB values?
2011/12/13 Nico Schlömer : > Hi, > > upon extracting the face color of a matplotlib.path.Path object, > > fc = obj.get_facecolor() > > I always seem to get an array of length 4. This initially led me to > believe I'm dealing with CMYK values, but it really seems like the > last entry is *always* 1.0 and the first three give the RGB > representation of the respective color. > Is there any documentation on color codes usage in matplotlib? > > Cheers, > Nico >... Hi, maybe: http://matplotlib.sourceforge.net/api/colors_api.html#module-matplotlib.colors "RGB and RGBA are sequences of, respectively, 3 or 4 floats in the range 0-1." hth, vbr -- Systems Optimization Self Assessment Improve efficiency and utilization of IT resources. Drive out cost and improve service delivery. Take 5 minutes to use this Systems Optimization Self Assessment. http://www.accelacomm.com/jaw/sdnl/114/51450054/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] get_facecolor() returns 4-tuple, contains RGB values?
Hi, upon extracting the face color of a matplotlib.path.Path object, fc = obj.get_facecolor() I always seem to get an array of length 4. This initially led me to believe I'm dealing with CMYK values, but it really seems like the last entry is *always* 1.0 and the first three give the RGB representation of the respective color. Is there any documentation on color codes usage in matplotlib? Cheers, Nico -- Systems Optimization Self Assessment Improve efficiency and utilization of IT resources. Drive out cost and improve service delivery. Take 5 minutes to use this Systems Optimization Self Assessment. http://www.accelacomm.com/jaw/sdnl/114/51450054/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] contourf: matplotlib.path.Path are LINETOs?
Hi all, when drawing contourf plots, I inspected the underlying matplotlib.path.Path elements that determine the curves and noticed that they are all of code LINETO (see http://matplotlib.sourceforge.net/api/path_api.html#matplotlib.path.Path) although the number of vertices is 6, actually suggesting a CURVE4. Would that be a bug? Cheers, Nico -- Systems Optimization Self Assessment Improve efficiency and utilization of IT resources. Drive out cost and improve service delivery. Take 5 minutes to use this Systems Optimization Self Assessment. http://www.accelacomm.com/jaw/sdnl/114/51450054/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] 3D plotting
Hello, I have 2D array where each (x, y) cell represents the height of that point on the Z axis (you can think of it as the map of some mountain chain). I'd like to get the plot_surface() of this data. What I don't understand in particular is the content of the X, Y ,Z array parameter in my particular example. Can anybody elaborate on this please? Thanks! Claudio -- Claudio Martella claudio.marte...@vu.nl -- Systems Optimization Self Assessment Improve efficiency and utilization of IT resources. Drive out cost and improve service delivery. Take 5 minutes to use this Systems Optimization Self Assessment. http://www.accelacomm.com/jaw/sdnl/114/51450054/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] [ploting data] Live data
Yeah I didn't think about suggesting that, but I think it might get complicated. I think he would have to start a one shot timer to call a function to set the voltage. Then that function would also start another one shot timer to call another function that would read from the sample. That function then would start a one shot timer to call the first function again. This way he can be sure that things are called in order and that timing is consistent, just in case the GUI gets complicated or something makes the event loop slow down. He could also use multiple threads. Whatever works for Fabien I guess. -Dave On 12/13/11 1:00 PM, matplotlib-users-requ...@lists.sourceforge.net wrote: > From: "Drain, Theodore R (343P)" > Subject: Re: [Matplotlib-users] [ploting data] Live data > > Perhaps I'm missing something, but why not use QTimer? You can't really > every call sleep in a single threaded gui (for reasons you've encountered). > If you need to poll something, create a QTimer for 2 seconds and have it call > a measurement function to update the data. You shouldn't need any > processEvents calls or sleep. -- Systems Optimization Self Assessment Improve efficiency and utilization of IT resources. Drive out cost and improve service delivery. Take 5 minutes to use this Systems Optimization Self Assessment. http://www.accelacomm.com/jaw/sdnl/114/51450054/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Plot Fill with Jacobian Coordinates
On Mon, Dec 12, 2011 at 7:03 PM, Benjamin Root wrote: > On Sat, Dec 10, 2011 at 10:36 AM, Alex Naysmith > wrote: > >> Hello, >> >> I'm trying to plot the stresses in colour of a strained isoparametric >> element. >> >> I have a six noded triangle with vertice coordinates >> [(xa1,ya1),(xa2,ya2),(xa3,ya3)] = pos_a >> >> This triangle deforms and the new coordinate positions are >> [(xb1,yb1),(xa2,yb2),(xb3,yb3)] = pos_b >> >> The remaining nodes are mid nodes also with rest and deformed coordinate >> positions. >> >> To plot the edges of the triangle I use a Jacobian transformation >> function so that the coordinates of the triangle are in Jacobian >> coordinates xi1 and xi2 (with xi3 = 1 - xi1 - xi2). This is required as the >> elements are quadratic with mid-nodes. >> >> Each interval is hard coded so that: >> xi1 = [1.0,0.9,0.8,0.7,0.6,0.5, etc..] >> xi2 = [0.0,0.1,0.2,0.3,0.4,0.5, etc..] >> >> I would like to plot the strains in colour so that the interior of the >> triangle is filled but I don't want to hard code the Jacobian intervals as >> this seems an awkward way of doing it. >> >> With strain as a function of xi1 and xi2, How can matplotlib provide a >> continuous interior strain plot of the triangle for all the xi1 and xi2 >> values from 0 to 1? >> >> Regards >> >> Alex Naysmith >> >> > Alex, > > Perhaps if you can provide an example figure, we might be able to better > help you. Right now, I am having trouble envisioning what you describe. > > Ben Root > > Ben, I have created a script that uses one isoparametric triangle as an example. The triangle nodes undergo a displacement, resulting in strains inside the triangle. The new script calculates the strains inside the triangle for a range of xi1 and xi2 barycentric coordinates and returns the global coordinates with the corresponding strain. I would like matplotlib to give me a nice interpolated colour plot of the strains inside the triangle, but as the output global coordinates are not aligned in neat rows and columns, I cannot do a straightforward meshgrid plot with imshow. http://bazaar.launchpad.net/~eckeroo/misc/mpl_scripts/files There are further comments in the script that may explain things better. I want a figure like this: http://matplotlib.sourceforge.net/examples/pylab_examples/animation_demo.html But for a 6 noded quadratic triangle instead of square. The intention is to have all the triangles in the mesh display their strains with interpolated colours. Regards Alex -- Systems Optimization Self Assessment Improve efficiency and utilization of IT resources. Drive out cost and improve service delivery. Take 5 minutes to use this Systems Optimization Self Assessment. http://www.accelacomm.com/jaw/sdnl/114/51450054/___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] [ploting data] Live data
Perhaps I'm missing something, but why not use QTimer? You can't really every call sleep in a single threaded gui (for reasons you've encountered). If you need to poll something, create a QTimer for 2 seconds and have it call a measurement function to update the data. You shouldn't need any processEvents calls or sleep. From: Fabien Lafont [lafont.fab...@gmail.com] Sent: Tuesday, December 13, 2011 12:30 AM To: David Hoese Cc: matplotlib-users@lists.sourceforge.net Subject: Re: [Matplotlib-users] [ploting data] Live data Hey David, I'm doing this program to control an experiment, so I want to put the voltage on the sample, then wait two seconds to be sure there is no current fluctuations then measure the curent with multimeters and finally plot the datas. That's why I need the "sleep"... In fact I wanted to use in parallel the timer to "refresh" the graph and a while loop to "extract" the datas. If I use startTimer(0) it works but the GUI is almost unresponsive. I'm trying to use qApp.processEvents() but up to now I don't manage to see the window appears... Thanks again for your help Fabien 2011/12/12 David Hoese : > Hey Fabien, > > So you made your principal function run on a timer every 2 seconds? And by > "lag" do you mean that the GUI is unresponsive? I'm still not seeing when > the loop stops, but what you can do is set the timer at a 0 interval so it > will call the principal function as fast as it can (but with no loop). The > problem with this is that you have those 2 sleep calls in the function. I'm > not sure why you have the sleeps, but if you need them you have two choices: > > 1. Make you GUI multi-threaded and you could emit a Qt signal from the data > thread when the GUI thread needs to update the GUI. Yes this could get > complicated, but if the sleeps are required then its probably the best way. > > 2. (From what I've been told, the Qt experts don't approve this) You can use > app.processEvents() in your loop (after each sleep maybe) and this will > pause your function and tell the main event loop to process any queued > events (like GUI actions/events) which will make your GUI more responsive. > > If that doesn't make sense let me know. > > -Dave > > > On 12/12/11 9:16 AM, Fabien Lafont wrote: >> >> Hi David! Sorry about the delay I was abroad and without any way to >> connect to the internet. >> >> Thank you very much. I've tried to put the principal inside the >> timerEvent. It work but it lags. In fact I've set the interval of the >> Timer to 2 seconds because the principal loop takes roughly 2seconds >> but it's not very accurate... >> >> Is there a way to do the principal loop, show it on the screen, then >> redo the loop? >> >> Thanks again! >> >> Fabien >> >> 2011/12/5 David Hoese: >>> >>> If I'm understanding your question correctly and reading your code >>> correctly, you're asking why the timer method of doing things works, but the >>> principal() while loop method does not. >>> >>> I had a couple solutions that involved the main event loop, but I just >>> noticed 2 main things that are probably wrong with your code: >>> 1. You are calling 'principal' from inside __init__ so you never actually >>> return from __init__ which means that you never call "window.show()" and >>> therefore never call "qApp.exec_()". If you really want to use the >>> 'principal' method you would have to connect it to a one shot timer anyway >>> to have it run after you have started the application ('qApp.exec_()'). I >>> think the recommended way would be to use the timer the way you did in your >>> latest email. >>> >>> 2. At least in the way my email client reads your original code, your >>> calls to the matplotlib drawing functions aren't inside the while loop and >>> the while loop never ends...although this doesn't matter if you don't fix #1 >>> above. >>> >>> Hope that made sense. >>> >>> -Dave >>> >>> >>> On 12/5/11 1:44 PM, matplotlib-users-requ...@lists.sourceforge.net wrote: Message: 3 Date: Mon, 5 Dec 2011 15:46:02 +0100 From: Fabien Lafont Subject: Re: [Matplotlib-users] [ploting data] Live data Cc:matplotlib-users@lists.sourceforge.net Message-ID: Content-Type: text/plain; charset=ISO-8859-1 Thx all for your remarks, I can't understand why this code works (when I use the timer method): >>> >>> >>> >>> -- >>> All the data continuously generated in your IT infrastructure >>> contains a definitive record of customers, 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-novd2d >>> ___ >>> Matplotlib-users mailing list >>> Matplotlib-users@lists.sourceforge.net >>> https://lists.sourceforge.net/lists/listinfo/matp
[Matplotlib-users] plot_date issue : OverflowError: date value out of range
Hi all. I'm trying to use plot_date and I get an error I don't understand. I've reduced my problem to this small example: - from pylab import figure, show dates = [301,302,303] #dates = [1,2,303] #dates = [1,2,3] values = [1,2,4] fig = figure() ax = fig.add_subplot(111) ax.plot_date(dates, values,'-') fig.autofmt_xdate() show() - This works. I get a plot with the values for the 301st, 302nd and 303rd day of year one. (I don't actually mind the year, all I know is my simulation starts the first of january of any year.) If I use dates = [1,2,303], it works as well. However, with dates = [1,2,3], it does not, and I get the error : OverflowError: date value out of range I don't understand. I may not be aware of everything concerning dates in python, but as far as I understand, those dates are correct and are the first three days of year one. Aren't they ? Since I don't mind the year, I guess I could add an arbitrary number of years to my dates as a workaround for this error. Another question that could be related: http://www.mail-archive.com/matplotlib-users@lists.sourceforge.net/msg01720.html Thanks for any help. -- Jérôme -- Systems Optimization Self Assessment Improve efficiency and utilization of IT resources. Drive out cost and improve service delivery. Take 5 minutes to use this Systems Optimization Self Assessment. http://www.accelacomm.com/jaw/sdnl/114/51450054/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Fonts question.
*Hi folks, * * * *I try to use the PDF backend in my plotting script, when I expect to have a pdf figure. However, when I open the figure in Adobe Illustrator, it turns out that the fonts are not "real fonts". I mean I want to be able to directly edit them. For example, when I double click the fonts or use other ways, I want to edit the fonts without deleting them and replacing with new ones. Am I missing something or not doing it correctly? * * * *Sample: * * # use PDF backends import matplotlib matplotlib.use('PDF') import matplotlib.pyplot as plt .. fig = plt.figure() .. fig.savefig('sample.pdf') **Best, Hongchun * -- Systems Optimization Self Assessment Improve efficiency and utilization of IT resources. Drive out cost and improve service delivery. Take 5 minutes to use this Systems Optimization Self Assessment. http://www.accelacomm.com/jaw/sdnl/114/51450054/___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] [SciPy-User] matplotlib: Simple legend code no longer works after upgrade to Ubuntu 11.10
On Mon, Dec 12, 2011 at 7:05 PM, C Barrington-Leigh wrote: > Oops; I just posted this to comp.lang.python, but I wonder whether > matplotlib questions are supposed to go to scipy-user? How about matplotlib-users@lists.sourceforge.net? I've cc'ed to that list. Warren > Here it is: > """ > Before I upgraded to 2.7.2+ / 4 OCt 2011, the following code added a > comment line to an axis legend using matplotlib / pylab. > Now, the same code makes the legend appear "off-screen", ie way > outside the axes limits. > > Can anyone help? And/or is there a new way to add a title and footer > to the legend? > > Thanks! > """ > > from pylab import * > plot([0,0],[1,1],label='Ubuntu 11.10') > lh=legend(fancybox=True,shadow=False) > lh.get_frame().set_alpha(0.5) > > from matplotlib.offsetbox import TextArea, VPacker > fontsize=lh.get_texts()[0].get_fontsize() > legendcomment=TextArea('extra comments here', > textprops=dict(size=fontsize)) > show() > # Looks fine here > lh._legend_box = VPacker(pad=5, > sep=0, > children=[lh._legend_box,legendcomment], > align="left") > lh._legend_box.set_figure(gcf()) > draw() > > > ___ > SciPy-User mailing list > scipy-u...@scipy.org > http://mail.scipy.org/mailman/listinfo/scipy-user > -- Systems Optimization Self Assessment Improve efficiency and utilization of IT resources. Drive out cost and improve service delivery. Take 5 minutes to use this Systems Optimization Self Assessment. http://www.accelacomm.com/jaw/sdnl/114/51450054/___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] [ploting data] Live data
Fabien, The GUI not being responsive might be my fault, I've never used a timer of 0 and processEvents(). I think what might be happening is that when you call processEvents, the timer of 0 calls your principal function again, which calls processEvents again, and so on. Try a timer of 2 again, that "should" stop the timer from being constantly triggered. Later today, once I get to work, I'll run some tests of my own and figure out if that's really the problem. Email me if you make any progress. -Dave On 12/13/2011 2:30 AM, Fabien Lafont wrote: > Hey David, > > I'm doing this program to control an experiment, so I want to put the > voltage on the sample, then wait two seconds to be sure there is no > current fluctuations then measure the curent with multimeters and > finally plot the datas. That's why I need the "sleep"... In fact I > wanted to use in parallel the timer to "refresh" the graph and a while > loop to "extract" the datas. > > If I use startTimer(0) it works but the GUI is almost unresponsive. > I'm trying to use qApp.processEvents() but up to now I don't manage to > see the window appears... > > Thanks again for your help > > Fabien > > > > 2011/12/12 David Hoese: >> Hey Fabien, >> >> So you made your principal function run on a timer every 2 seconds? And by >> "lag" do you mean that the GUI is unresponsive? I'm still not seeing when >> the loop stops, but what you can do is set the timer at a 0 interval so it >> will call the principal function as fast as it can (but with no loop). The >> problem with this is that you have those 2 sleep calls in the function. I'm >> not sure why you have the sleeps, but if you need them you have two choices: >> >> 1. Make you GUI multi-threaded and you could emit a Qt signal from the data >> thread when the GUI thread needs to update the GUI. Yes this could get >> complicated, but if the sleeps are required then its probably the best way. >> >> 2. (From what I've been told, the Qt experts don't approve this) You can use >> app.processEvents() in your loop (after each sleep maybe) and this will >> pause your function and tell the main event loop to process any queued >> events (like GUI actions/events) which will make your GUI more responsive. >> >> If that doesn't make sense let me know. >> >> -Dave >> >> >> On 12/12/11 9:16 AM, Fabien Lafont wrote: >>> >>> Hi David! Sorry about the delay I was abroad and without any way to >>> connect to the internet. >>> >>> Thank you very much. I've tried to put the principal inside the >>> timerEvent. It work but it lags. In fact I've set the interval of the >>> Timer to 2 seconds because the principal loop takes roughly 2seconds >>> but it's not very accurate... >>> >>> Is there a way to do the principal loop, show it on the screen, then >>> redo the loop? >>> >>> Thanks again! >>> >>> Fabien >>> >>> 2011/12/5 David Hoese: If I'm understanding your question correctly and reading your code correctly, you're asking why the timer method of doing things works, but the principal() while loop method does not. I had a couple solutions that involved the main event loop, but I just noticed 2 main things that are probably wrong with your code: 1. You are calling 'principal' from inside __init__ so you never actually return from __init__ which means that you never call "window.show()" and therefore never call "qApp.exec_()". If you really want to use the 'principal' method you would have to connect it to a one shot timer anyway to have it run after you have started the application ('qApp.exec_()'). I think the recommended way would be to use the timer the way you did in your latest email. 2. At least in the way my email client reads your original code, your calls to the matplotlib drawing functions aren't inside the while loop and the while loop never ends...although this doesn't matter if you don't fix #1 above. Hope that made sense. -Dave On 12/5/11 1:44 PM, matplotlib-users-requ...@lists.sourceforge.net wrote: > > Message: 3 > Date: Mon, 5 Dec 2011 15:46:02 +0100 > From: Fabien Lafont > Subject: Re: [Matplotlib-users] [ploting data] Live data > Cc:matplotlib-users@lists.sourceforge.net > Message-ID: > > > Content-Type: text/plain; charset=ISO-8859-1 > > Thx all for your remarks, > > I can't understand why this code works (when I use the timer method): -- All the data continuously generated in your IT infrastructure contains a definitive record of customers, 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-novd2d ___ Matpl
Re: [Matplotlib-users] [ploting data] Live data
Hey David, I'm doing this program to control an experiment, so I want to put the voltage on the sample, then wait two seconds to be sure there is no current fluctuations then measure the curent with multimeters and finally plot the datas. That's why I need the "sleep"... In fact I wanted to use in parallel the timer to "refresh" the graph and a while loop to "extract" the datas. If I use startTimer(0) it works but the GUI is almost unresponsive. I'm trying to use qApp.processEvents() but up to now I don't manage to see the window appears... Thanks again for your help Fabien 2011/12/12 David Hoese : > Hey Fabien, > > So you made your principal function run on a timer every 2 seconds? And by > "lag" do you mean that the GUI is unresponsive? I'm still not seeing when > the loop stops, but what you can do is set the timer at a 0 interval so it > will call the principal function as fast as it can (but with no loop). The > problem with this is that you have those 2 sleep calls in the function. I'm > not sure why you have the sleeps, but if you need them you have two choices: > > 1. Make you GUI multi-threaded and you could emit a Qt signal from the data > thread when the GUI thread needs to update the GUI. Yes this could get > complicated, but if the sleeps are required then its probably the best way. > > 2. (From what I've been told, the Qt experts don't approve this) You can use > app.processEvents() in your loop (after each sleep maybe) and this will > pause your function and tell the main event loop to process any queued > events (like GUI actions/events) which will make your GUI more responsive. > > If that doesn't make sense let me know. > > -Dave > > > On 12/12/11 9:16 AM, Fabien Lafont wrote: >> >> Hi David! Sorry about the delay I was abroad and without any way to >> connect to the internet. >> >> Thank you very much. I've tried to put the principal inside the >> timerEvent. It work but it lags. In fact I've set the interval of the >> Timer to 2 seconds because the principal loop takes roughly 2seconds >> but it's not very accurate... >> >> Is there a way to do the principal loop, show it on the screen, then >> redo the loop? >> >> Thanks again! >> >> Fabien >> >> 2011/12/5 David Hoese: >>> >>> If I'm understanding your question correctly and reading your code >>> correctly, you're asking why the timer method of doing things works, but the >>> principal() while loop method does not. >>> >>> I had a couple solutions that involved the main event loop, but I just >>> noticed 2 main things that are probably wrong with your code: >>> 1. You are calling 'principal' from inside __init__ so you never actually >>> return from __init__ which means that you never call "window.show()" and >>> therefore never call "qApp.exec_()". If you really want to use the >>> 'principal' method you would have to connect it to a one shot timer anyway >>> to have it run after you have started the application ('qApp.exec_()'). I >>> think the recommended way would be to use the timer the way you did in your >>> latest email. >>> >>> 2. At least in the way my email client reads your original code, your >>> calls to the matplotlib drawing functions aren't inside the while loop and >>> the while loop never ends...although this doesn't matter if you don't fix #1 >>> above. >>> >>> Hope that made sense. >>> >>> -Dave >>> >>> >>> On 12/5/11 1:44 PM, matplotlib-users-requ...@lists.sourceforge.net wrote: Message: 3 Date: Mon, 5 Dec 2011 15:46:02 +0100 From: Fabien Lafont Subject: Re: [Matplotlib-users] [ploting data] Live data Cc:matplotlib-users@lists.sourceforge.net Message-ID: Content-Type: text/plain; charset=ISO-8859-1 Thx all for your remarks, I can't understand why this code works (when I use the timer method): >>> >>> >>> >>> -- >>> All the data continuously generated in your IT infrastructure >>> contains a definitive record of customers, 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-novd2d >>> ___ >>> Matplotlib-users mailing list >>> Matplotlib-users@lists.sourceforge.net >>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > -- Systems Optimization Self Assessment Improve efficiency and utilization of IT resources. Drive out cost and improve service delivery. Take 5 minutes to use this Systems Optimization Self Assessment. http://www.accelacomm.com/jaw/sdnl/114/51450054/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Plotting basemap on top of other data
# This is a piece of code that I actually used to try to solve the problem # Just assumed that I have an int32 array ("data") with satellite data of dimensions [x,y,3] filled with RGB values ... I have removed the reading of satellite sample data, which is not relevant here. # The satellite (geostationary) is located above the equator at zero degrees east # in this example I want a plot with 300 dpi resolution. import numpy import matplotlib.pyplot as plt dpi = 300 fig = plt.figure(figsize=[data.shape[0]/dpi,data.shape[1]/dpi]) ax = plt.axes([0,0,1,1], frameon = False) ax.set_axis_off() im = ax.imshow(data, origin='None') from mpl_toolkits.basemap import Basemap map = Basemap(projection='ortho', lat_0 = 0, lon_0 = 0, resolution = 'l', area_thresh = 1000.) map.drawcoastlines() fig.savefig('figure.png', format='png', dpi=dpi) -Original Message- From: Patrick Marsh [mailto:patrickmars...@gmail.com] Sent: zaterdag 10 december 2011 23:41 To: Laat de, Jos (KNMI) Cc: matplotlib-users@lists.sourceforge.net Subject: Re: [Matplotlib-users] Plotting basemap on top of other data HI, My initial thought was that you need to use the "zorder" keyword argument and set the zorder to a large value. However, the more I thought about it, I'm not really sure how you are plotting the satellite data. Can you provide a code snippet? PTM --- Patrick Marsh Ph.D. Student / Liaison to the HWT School of Meteorology / University of Oklahoma Cooperative Institute for Mesoscale Meteorological Studies National Severe Storms Laboratory http://www.patricktmarsh.com -- Systems Optimization Self Assessment Improve efficiency and utilization of IT resources. Drive out cost and improve service delivery. Take 5 minutes to use this Systems Optimization Self Assessment. http://www.accelacomm.com/jaw/sdnl/114/51450054/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users