Re: [Matplotlib-users] Placing a marker at specific places where lines join?
Why don't you just use the code provided here: http://matplotlib.sourceforge.net/examples/api/watermark_image.html The first thing to do when you want to plot something is maybe to look at the examples section, isn't it? It shows pretty good how to not only mark points, but also to mark points with semi-transparent circles. Please keep in mind: Plotting a set of lines and mark several points produces exactly the same image as plotting a set of lines and, above that, plot a set of circles. Maybe there are cleaner solutions, but to get an impression how to do things this might be enough. Cheers Philipp -- 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
[Matplotlib-users] tick labels in colorbar?
Hi, I'm plotting a colorbar with pylab.colorbar(ticks=(-pi,0,pi)) and trying to add proper \pi labels to it. Couldn't find out how to do that from the manual -- any hints here? Cheers, Nico -- 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] Placing a marker at specific places where lines join?
On Sat, Feb 13, 2010 at 11:28 PM, Wayne Watson sierra_mtnv...@sbcglobal.net wrote: Well, I'm not quite sure what to say to your claim. In certain instances I am trying to get through to someone here that something is missing for newbies. In one word, pedagogy (as perhaps in a text book, not a reference manual or dictionary). I'm trying to be positive about it, and not negative. Positive criticism I hope. I apologize if I offend you. The main matplotlib documentation has a section called user's guide (http://matplotlib.sourceforge.net/contents.html). And the third item in the user's guide is pyplot tutorial. So, I believe anyone who're willing to learn matplotlib, is willing to read through some sections of the user's guide and at least the tutorial. Is my standard too high? I'm not saying that the documentation is complete, and any suggestion (or even contribution) will be very appreciated. However, while you're saying that pedagogy is missing in our documentation, but it seems like that you haven't even read the very basic tutorial (because, as John said, the answer to your original question is in that tutorial). And I doubt how this could be positive criticism (while I understand you want to be positive). Anyhow, for your original question, try plot([0, 1, 2], [0, 1.5, 2], -) plot([1], [1.5], go) -JJ -- 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] Placing a marker at specific places where lines join?
Dear Wayne Watson, As yourself I'm also new to matplotlib (and python) and I know that learning such a library can be overwhelming at first. Still, this community/mailist has answered all my newbie questions, even when they were clearly in the manual or have already been answered in previous posts. All this free of charge! We actually have the privilege of having the developers inhabiting the user list! This is not true in many users-lists that I dwell. You mentioned matlab in your message as the way to go. If your project has a budget for license and support, maybe that is indeed the way to go. Otherwise, if you come from a matlab background as myself, you might be interested in these two links: http://www.scipy.org/NumPy_for_Matlab_Users and http://mathesaurus.sourceforge.net/matlab-numpy.html They are not matplotlib references, but help to understand how things are done before you fire-a-plot. Hope that help you in your learning adventure. Also, you might find useful to read this: http://www.freebsd.org/doc/en/articles/mailing-list-faq/etiquette.html It is BSD related, but most is true for any maillist. Best, Filipe On Sat, Feb 13, 2010 at 9:03 PM, Wayne Watson sierra_mtnv...@sbcglobal.netwrote: Suppose I plot a line from (0,0) to (1,1.5) to (2,2). Now I want to mark (1,1.5) with a green circle. How is that done? -- Crime is way down. War is declining. And that's far from the good news. -- Steven Pinker (and other sources) Why is this true, but yet the media says otherwise? The media knows very well how to manipulate us (see limbic, emotion, $$). -- WTW -- 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] How Does One Learn to Use MatPlotLib?
Not read it myself but 'Matplotlib for Python Developers' might be what you're after - see review http://dalelane.co.uk/blog/?p=1222 Best way to learn Matplotlib is to use a good IDE like Spyder. I find it much easier than IPython. http://code.google.com/p/spyderlib/ Installing Python(x,y) is the easiest way to set it all up. Doug Wayne Watson wrote: Thanks for the info. I'm semi-resistant to ipython. I tried if for a few hours, and it seemed a bit too much like linux. Years ago I used linux a lot, and enjoyed it. I'll consider it. Windows is the game now. Yes, actual use is good, but the needed imports seem a bit baffling. scipy, pylab, matplotlib, ...? What components do I only need for a particular use? The videos you mentioned could be helpful. I do not belong to any group, and my small town is a long way from any educational resources.What I learn is from a few books, FAQs, and recently the MPL Guide. Within a 50 mile radius, I know exactly one other person who knows Python. He's a very bright high school student. On 2/9/2010 10:33 PM, Gökhan Sever wrote: On Tue, Feb 9, 2010 at 8:15 PM, Wayne Watson lt; sierra_mtnv...@sbcglobal.net gt; wrote: Subject is the question. As I see it, it's useful to know MatLab. A simple query with matplotlib tutorial shows a number of hits. The first, reference to v0.99.a documentation barely qualifies. Examples galore and a pretty minimal introduction. In the first 10 or so hits ther's a blog and mention of a video. The blog may appeal to some, but it seems unelementary. The video basically asks to sign in. Who knows where that goes? I've seen a few videos for MPL, but they all look tied into $$. I've made some reasonable progress on MPL, but am still far short of being confident of using it. Too much try this and see. I know of exactly one book on MPL ( for scientists. sounds interesting). It was published recently by a foreign author. It is not yet widely distributed. Your turn. Comments? -- Crime is way down. War is declining. And that's far from the good news. -- Steven Pinker (and other sources) Why is this true, but yet the media says otherwise? The media knows very well how to manipulate us (see limbic, emotion, $$). -- WTW -- 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 For me best way to learn is to use it actually :) Especially on homework and projects. Mailing lists are also very helpful as you are already doing. Try with ipython --pylab option. Also check SciPy09 ( http://conference.scipy.org/SciPy2009/ ) videos. There are one introductory and advanced tutorials that you can see online (without registering) or downloading to your computer. -- Gökhan -- Crime is way down. War is declining. And that's far from the good news. -- Steven Pinker (and other sources) Why is this true, but yet the media says otherwise? The media knows very well how to manipulate us (see limbic, emotion, $$). -- WTW -- 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 -- View this message in context: http://old.nabble.com/How-Does--One-Learn-to-Use-MatPlotLib--tp27525289p27564958.html Sent from the matplotlib - users mailing list archive at Nabble.com. -- 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] tick labels in colorbar?
Hi Nico, I didn't test it, but maybe with something like that: rc('text', usetex=True) [taken from http://matplotlib.sourceforge.net/plot_directive/mpl_examples/pylab_examples/tex_demo.py] ax.set_xticks((-pi,pi)) ax.set_xticklabels(('$-\pi$','$\pi$')) [taken from http://matplotlib.sourceforge.net/examples/pylab_examples/integral_demo.html] Cheers, Philipp -- 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] Placing a marker at specific places where lines join?
Did you see the figure I included to John? If not, let me put it simply. Suppose you have 50 straight sticks connected at their ends with some hook. I want to color the hook holding stick 10 to 11, but color no other hook. Not 99 hooks. Yesterday, I tried to do a simple plot of three points without markers. Worked fine. I then tried something like plot(1,2,bs). I got an error . I tried variations on the plot with qualifiers. Zero. That seems like it should put the marker right at (1,2). My immediate reaction to your example, is that it colors every hook. Am I missing something in your example? On 2/14/2010 1:13 AM, Philipp Bender wrote: Why don't you just use the code provided here: http://matplotlib.sourceforge.net/examples/api/watermark_image.html The first thing to do when you want to plot something is maybe to look at the examples section, isn't it? It shows pretty good how to not only mark points, but also to mark points with semi-transparent circles. Please keep in mind: Plotting a set of lines and mark several points produces exactly the same image as plotting a set of lines and, above that, plot a set of circles. Maybe there are cleaner solutions, but to get an impression how to do things this might be enough. Cheers Philipp -- 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 -- Crime is way down. War is declining. And that's far from the good news. -- Steven Pinker (and other sources) Why is this true, but yet the media says otherwise? The media knows very well how to manipulate us (see limbic, emotion, $$). -- WTW -- 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] How to blank an area of the canvas?
Brendan Barnwell wrote: I'm trying to find the quickest way to erase a rectangular area of the figure canvas. I tried using canvas.restore_region with the optional bbox argument, but there seems to be some mismatch between the measurement units of the saved buffer object and the currently shown data. For instance, if I have a Text object on my plot, I tried this: bbox = g.text.get_window_extent() canvas.restore_region(background, bbox) . . . but it does not correctly block out the text. (The restored rectangle from the background appears elsewhere on the axes.) How can I convert the buffer coordinates to the coordinates of the the displayed plot? I'm sorry to bump my own post, but I would really appreciate some help with this. I've been wrestling with it for a couple days now, and I cannot figure out how the coordinate system of the saved canvas is related to the axes coordinates. I have found that with bbox.transformed(ax.transData) I can at least get the coordinates scaled to fit on the axes, but they are still offset in position from where the box actually appears on the canvas. I can't figure out how to compute this offset. By playing around with the coordinates manually, for instance, I've found that adjusting x by -52 and y by 21 appears to line up the canvas with the axes, but I can't see where these numbers -52 and 21 would come from. My saved canvas buffer's get_extents() method returns (65, 50, 586, 443), so I thought that the appropriate offsets would be 65 and 50, but that doesn't work. So, what coordinates (x1, y1, x2, y2) do I need to use in canvas.restore_region(savedBuffer, (x1, y1, x2, y2)) in order to restore precisely the area of canvas occupied by a patch drawn at axis coordinates (a1, b1, a2, b2)? Thanks? -- Brendan Barnwell Do not follow where the path may lead. Go, instead, where there is no path, and leave a trail. --author unknown -- 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] Placing a marker at specific places where lines join?
Thank you for the code below. Yes, it actually does what I want it to do. The difference in what I did similarly yesterday (see my response to Philipp moments ago) is the [ ], a list. All this for one simple bit of list notation. Somehow I'm not getting through to anyone what I have actually read. I do not plan to repeat it again here. If I have some time in the near future, I will write a line by line criticism of the basic tutorial. OK, maybe the first page*. I already made some remarks about 5-6 days ago about that document. I think it was that one. I'll submit it to one of the lists John provided on where I should send issues about the guide. Now to put an end to the show() question. See my next post in a few minutes. Subject is down another pathway I think. * Subject is FAQ Page Needs Some Work On 2/14/2010 6:29 AM, Jae-Joon Lee wrote: On Sat, Feb 13, 2010 at 11:28 PM, Wayne Watson sierra_mtnv...@sbcglobal.net wrote: Well, I'm not quite sure what to say to your claim. In certain instances I am trying to get through to someone here that something is missing for newbies. In one word, pedagogy (as perhaps in a text book, not a reference manual or dictionary). I'm trying to be positive about it, and not negative. Positive criticism I hope. I apologize if I offend you. The main matplotlib documentation has a section called user's guide (http://matplotlib.sourceforge.net/contents.html). And the third item in the user's guide is pyplot tutorial. So, I believe anyone who're willing to learn matplotlib, is willing to read through some sections of the user's guide and at least the tutorial. Is my standard too high? I'm not saying that the documentation is complete, and any suggestion (or even contribution) will be very appreciated. However, while you're saying that pedagogy is missing in our documentation, but it seems like that you haven't even read the very basic tutorial (because, as John said, the answer to your original question is in that tutorial). And I doubt how this could be positive criticism (while I understand you want to be positive). Anyhow, for your original question, try plot([0, 1, 2], [0, 1.5, 2], -) plot([1], [1.5], go) -JJ -- Crime is way down. War is declining. And that's far from the good news. -- Steven Pinker (and other sources) Why is this true, but yet the media says otherwise? The media knows very well how to manipulate us (see limbic, emotion, $$). -- WTW -- 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
[Matplotlib-users] Python 3
All, Can anyone shed light on how python 3 is working together with matplotlib, scipy, and numpy? David -- 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] Placing a marker at specific places where lines join?
Hi Wayne, (I wanted to answer you directly but the mail came back, don't know why) I have several points that you really should work on if you expect anyone to answer to your mails in future. First, you should check the destination of your messages. I got at least three of your messages addressed only for me, you obviously wanted to send them to the list but they only reached me. So I didn't answer because the mailing list should be an open and searchable discussion platform and I didn't want to forward your message to the list or something like that. Please check that carefully in future. The next thing is that everyone must have the feeling that you completely ignore replies. This link here should have been an alert for you: http://www.freebsd.org/doc/en/articles/mailing-list-faq/etiquette.html This was posted as reply to one of your mails. One thing explained there is to not cite the original mail after the own reply, instead you should cite the original issue at the beginning or in parts directly before the parts of the answer. See below: How to do foo bar? Just like that. You see? The same thing about your footnotes*. Another thing is the HTML I received from your adress two times -- HTML has neither benefit nor a good reputation in mailing lists. I delete HTML mails without reading it in most cases. And, but that's maybe more a personal thing, I find it very unfriendly to ask in the subject and write in the body something like (see subject) -- we take the time to read your message, in respect to that you also should take the time to ask a complete question. Please don't misunderstand this message -- I don't want to blame you, I want to help you and make sure that you get answers to your questions in future. Regards, Philipp * like this one here. They don't help you, they don't explain anything, they don't help me reading the message, they have absolutely no benefit. -- 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
[Matplotlib-users] turning off tick labels
Dear matplotters, I'm trying to follow http://matplotlib.sourceforge.net/examples/pylab_examples/ganged_plots.html as an example how to turn of the ticks in the case of shared x axes. The tick labels are gone, but unfortunately, matplotlib still plots a '1e5' on the axis for which I have turned off the tick labels. Please see the attached file for the problem How can I also switch of the exponent? Thanks, Jan attachment: photonPt_mc_unzoom.png-- 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
[Matplotlib-users] half-filled markers, two-colors
I ran across: http://old.nabble.com/half-filled-markers-td24003576.html The name fillstyle can give the wrong impression about what is being filled. For example, see the comment here: http://www.mail-archive.com/matplotlib-users@lists.sourceforge.net/msg13074.html It's probably too late, but would markerfillstyle be a better name for this? Also, the current implementation fills half of the marker with the markerfacecolor and doesn't fill the marker at all for the other half. I think a neat (and simple) feature would be for users to specify two colors. Perhaps 'markerfacecolor2'. The change to the code is minimal, but the functionality it brings is quite flexible. markerfacecolor2 can default to 'none' to maintain current functionality. Should I file a ticket for this? -- 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] Placing a marker at specific places where lines join?
Wayne Watson wrote: Thank you for the code below. Yes, it actually does what I want it to do. The difference in what I did similarly yesterday (see my response to Philipp moments ago) is the [ ], a list. All this for one simple bit of list notation. Newer versions of mpl do not require the list notation when plotting a single point. I don't recall when I made that change. Seems like quite a while ago, but evidently it was after the release you are using. Eric -- 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] How to blank an area of the canvas?
I have added a bbox support for restore_region, but I'm afraid that this feature is not well tested. And I guess what you find is, unfortunately, a bug. While I'll try to push the changes to the svn tomorrow, you may try to monkey-patch with following code. from matplotlib.transforms import Bbox, BboxBase from matplotlib.backends.backend_agg import RendererAgg def restore_region(self, region, bbox=None, xy=None): if bbox is not None or xy is not None: rx, ry, width, height = region.get_extents() if bbox is None: x1, y1, x2, y2 = region.get_extents() elif isinstance(bbox, BboxBase): x1, y1, x2, y2 = bbox.extents else: x1, y1, x2, y2 = bbox if xy is None: ox, oy = rx, ry else: ox, oy = xy self._renderer.restore_region2(region, x1, height-y2+ry, x2, height-y1+ry, ox, oy) else: self._renderer.restore_region(region) RendererAgg.restore_region = restore_region But, again, the code is not well tested and there could be another bug (or even this patch may introduce a new bug). So, see how it works and let know of any problem. However, while matplotlib does support some animation, I think you 'd better turn to another tool if you need an efficiency, Regards, -JJ On Sun, Feb 14, 2010 at 2:18 PM, Brendan Barnwell brenb...@brenbarn.net wrote: Brendan Barnwell wrote: I'm trying to find the quickest way to erase a rectangular area of the figure canvas. I tried using canvas.restore_region with the optional bbox argument, but there seems to be some mismatch between the measurement units of the saved buffer object and the currently shown data. For instance, if I have a Text object on my plot, I tried this: bbox = g.text.get_window_extent() canvas.restore_region(background, bbox) . . . but it does not correctly block out the text. (The restored rectangle from the background appears elsewhere on the axes.) How can I convert the buffer coordinates to the coordinates of the the displayed plot? I'm sorry to bump my own post, but I would really appreciate some help with this. I've been wrestling with it for a couple days now, and I cannot figure out how the coordinate system of the saved canvas is related to the axes coordinates. I have found that with bbox.transformed(ax.transData) I can at least get the coordinates scaled to fit on the axes, but they are still offset in position from where the box actually appears on the canvas. I can't figure out how to compute this offset. By playing around with the coordinates manually, for instance, I've found that adjusting x by -52 and y by 21 appears to line up the canvas with the axes, but I can't see where these numbers -52 and 21 would come from. My saved canvas buffer's get_extents() method returns (65, 50, 586, 443), so I thought that the appropriate offsets would be 65 and 50, but that doesn't work. So, what coordinates (x1, y1, x2, y2) do I need to use in canvas.restore_region(savedBuffer, (x1, y1, x2, y2)) in order to restore precisely the area of canvas occupied by a patch drawn at axis coordinates (a1, b1, a2, b2)? Thanks? -- Brendan Barnwell Do not follow where the path may lead. Go, instead, where there is no path, and leave a trail. --author unknown -- 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
[Matplotlib-users] Enter Figure on Macs
All, Any Mac users out there? This script from the User Guide does not seem to recognize entering or leaving a figure. Any thoughts? # enterleave.py import matplotlib.pyplot as plt def enter_axes(event): print 'enter_axes', event.inaxes event.inaxes.patch.set_facecolor('yellow') event.canvas.draw() def leave_axes(event): print 'leave_axes', event.inaxes event.inaxes.patch.set_facecolor('white') event.canvas.draw() def enter_figure(event): print 'enter_figure', event.canvas.figure event.canvas.figure.patch.set_facecolor('red') event.canvas.draw() def leave_figure(event): print 'leave_figure', event.canvas.figure event.canvas.figure.patch.set_facecolor('grey') event.canvas.draw() fig1 = plt.figure() fig1.suptitle('mouse hover over figure or axes to trigger events') ax1 = fig1.add_subplot(211) ax2 = fig1.add_subplot(212) fig1.canvas.mpl_connect('figure_enter_event', enter_figure) fig1.canvas.mpl_connect('figure_leave_event', leave_figure) fig1.canvas.mpl_connect('axes_enter_event', enter_axes) fig1.canvas.mpl_connect('axes_leave_event', leave_axes) fig2 = plt.figure() fig2.suptitle('mouse hover over figure or axes to trigger events') ax1 = fig2.add_subplot(211) ax2 = fig2.add_subplot(212) fig2.canvas.mpl_connect('figure_enter_event', enter_figure) fig2.canvas.mpl_connect('figure_leave_event', leave_figure) fig2.canvas.mpl_connect('axes_enter_event', enter_axes) fig2.canvas.mpl_connect('axes_leave_event', leave_axes) plt.show() David -- 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] memory leak for GTKAgg animation
On Sat, Feb 13, 2010 at 2:53 PM, John Jameson jjame...@altoresearch.com wrote: HI, I find the very basic animation below has a memory leak (my pagefile usage number keeps growing in the Windows XP Windows Task Manager Performance graph).I don't see this with the animation_blit_gtk.py example on: http://matplotlib.sourceforge.net/examples/index.html (which I used as a starting point for this). In animation_blit_gtk.py the set_ydata() routine is used to update the line for the animation and this does not leak. But if you call plot again with the new y_data (instead of using set_ydata), this leaks too. Anyone have an idea on how to stop the leak? This isn't a memory leak. The problem is that you keep adding new patches to the axes when you want just one with different data. Eg, in your loop, run this code, and you will see that the number of patches is growing: x_cir = 1.0 + 0.003*update_line.cnt cir = CirclePolygon((x_cir, 1), 0.3, animated=True, \ resolution=12, lw=2 ) ax.add_patch(cir) ax.draw_artist(cir) print 'num patches=%d, mem usage=%d'%( len(ax.patches), cbook.report_memory(update_line.cnt)) canvas.blit(ax.bbox) You should add just one patch and then manipulate the data. In this case, you are using a CirclePolygon which derives from RegularPolygon and so you can update the xy property http://matplotlib.sourceforge.net/api/artist_api.html#matplotlib.patches.RegularPolygon But on testing this it looks like there is a bug in that the set_xy property setter is ignored. I worked around this in the func below by setting the private variable directly, but this looks like a bug we need to fix (Michael, shouldn't we respect the xy passed in in patches.RegularPolygon._set_xy ?). In the meantime, the following workaround should work for you w/o leaking def update_line(): global x, y print update_line.cnt if update_line.background is None: update_line.background = canvas.copy_from_bbox(ax.bbox) canvas.restore_region(update_line.background) x_cir = 1.0 + 0.003*update_line.cnt if update_line.cir is None: cir = CirclePolygon((x_cir, 1), 0.3, animated=True, \ resolution=12, lw=2 ) ax.add_patch(cir) update_line.cir = cir else: update_line.cir._xy = x_cir, 1 update_line.cir._update_transform() ax.draw_artist(update_line.cir) print 'num patches=%d, xy=%s, mem usage=%d'%( len(ax.patches), update_line.cir.xy, cbook.report_memory(update_line.cnt)) canvas.blit(ax.bbox) if update_line.direction == 0: update_line.cnt += 1 if update_line.cnt 500: update_line.direction = 1 else: update_line.cnt -= 1 if update_line.cnt 100: update_line.direction = 0 return update_line.cnt100 update_line.cnt = 0 update_line.direction = 0 update_line.background = None update_line.cir = None -- 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] Enter Figure on Macs
On Sun, Feb 14, 2010 at 6:53 PM, David Arnold dwarnol...@suddenlink.net wrote: All, Any Mac users out there? This script from the User Guide does not seem to recognize entering or leaving a figure. Any thoughts? My Mac is currently dead, but I developed these events while I was a mac user and so am pretty sure they worked. It is more likely a specific backend problem than a Mac vs non-Mac problem (eg it may be specific to the macosx backend but not a problem for macs in general) http://matplotlib.sourceforge.net/faq/installing_faq.html#what-is-a-backend Could you try running the script with the use directive at the top of your script (before any other mpl code) for different backends, eg tkagg vs macosx vs wxagg import matplotlib matplotlib.use('tkagg') # and also try macosx and wxagg so we can see exactly where the problem is arising. Also, run your script with --verbose-helpful and report the debugging output. Looking at the code, it appears the enter_notify_event and leave_notify_event are only defined for wx, qt and gtk currently, and so need to be implemented for tk and macosx. JDH -- 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
[Matplotlib-users] Easy come easy go
All, This example: http://matplotlib.sourceforge.net/examples/event_handling/keypress_demo.html Raises this exception o my Macbook when the key 's' is pressed: The debugged program raised the exception unhandled TypeError save_figure() takes exactly 1 argument (2 given) File: /Library/Frameworks/Python.framework/Versions/6.0.0/lib/python2.6/site-packages/matplotlib/backend_bases.py, Line: 1703 David -- 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