[Matplotlib-users] Arrow question/request
Most of the plots I need to make for work have very different x and y axis scales, and under these conditions, the pyplot.arrow function (which I think is a FancyArrow) makes arrows where the heads are pretty distorted. (MPL version 0.99.1 -- Windows; version 0.99.1.1-r1 -- Gentoo) I've spent quite a bit of time learning about the different arrow classes -- FancyArrow, YAArrow, FancyArrowPatch -- and I've found that the FancyArrowPatch gives arrows that do not look distorted under these conditions. For examples: import matplotlib.pyplot as plt import matplotlib.patches as mpp fig = plt.figure() ax=fig.add_subplot(111) ax.axis([520,580, 0,0.2]) a = plt.arrow(550,0.06,15,0.1, width=0.01, head_length=1.) ax.add_patch(a) b = mpp.YAArrow(fig, (555,0.16), (540,0.06), width=0.01, headwidth=0.03) ax.add_patch(b) c = mpp.FancyArrowPatch((530,0.06), (545,0.16), arrowstyle='-|>', lw=2, mutation_scale=50) ax.add_patch(c) plt.show() However, this leads to my questions: 1) Are there any plans or would it make sense to add another keyword to the pyplot.arrow function that allows you to choose the arrow class you would like to use? The default could be FancyArrow so that the original usage of pyplot.arrow will not be affected. The axes.arrow function - which it looks like it gets called by the pyplot.arrow function - could then convert the input arguments into the form necessary for the class you choose. 2) Or... Is there a simple way that you can call the arrow function with start and end points in data coordinates, but have the arrow parameters calculated in normalized figure coordinates? I think FancyArrow calculates the head and body points using a line perpendicular to the line of the arrow in data coordinates, which I think is the source of my problem (? -- at least that is what I found doing some test calculations on my own). However, if I call the pyplot.arrow function with the following keywords, 'trasform=fig.transFigure, figure=fig' (as per the Artist tutorial, see below), then the arrow looks okay, but it needs to be positioned in normalized figure coordinates and it does not move when you zoom or translate the plot. d = plt.arrow(0.15, 0.3, 0.15, 0.4, head_width=0.05, transform=fig.transFigure, figure=fig) ax.add_patch(d) For me, this is not a really big concern now that I figured it out, but I'm trying to teach my coworkers how to use Python/Matplotlib, and although they are interested in learning both, most of them are not and probably never will be really strong Python programmers. As a consequence, I think that all of the different arrow options and usages outside of pyplot.arrow will be a bit confusing for them... (I know it was for me at first...) Sorry for the long question message. I hope it was clear. Ryan P.S. As this is my first message to the list, I wanted to thank everyone who contributes to this great project. I'm a fairly new Python and Matplotlib user (only about 7 or 8 months for Python, less for MPL), and the combination of Python/Numpy/Scipy/Matplotlib is by far the most useful tool that I've learned in quite a long time. Hopefully, someday I'll be skilled enough to contribute something back. -- View this message in context: http://old.nabble.com/Arrow-question-request-tp27590334p27590334.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] Enter Figure on Macs
John, Only the wxagg worked. Here is the output: $HOME=/Users/darnold CONFIGDIR=/Users/darnold/.matplotlib matplotlib data path /Library/Frameworks/Python.framework/Versions/6.0.0/lib/python2.6/site-packages/matplotlib/mpl-data loaded rc file /Users/darnold/.matplotlib/matplotlibrc matplotlib version 0.99.1.1 verbose.level helpful interactive is False units is False platform is darwin Using fontManager instance from /Users/darnold/.matplotlib/fontList.cache backend WXAgg version 2.8.10.1 findfont: Matching :family=sans-serif:style=normal:variant=normal:weight=normal:stretch=normal:size=medium to Bitstream Vera Sans (/Library/Frameworks/Python.framework/Versions/4.3.0/lib/python2.5/site-packages/matplotlib-0.98.5.2n2-py2.5-macosx-10.3-fat.egg/matplotlib/mpl-data/fonts/ttf/Vera.ttf) with score of 0.00 findfont: Matching :family=sans-serif:style=normal:variant=normal:weight=normal:stretch=normal:size=12.0 to Bitstream Vera Sans (/Library/Frameworks/Python.framework/Versions/4.3.0/lib/python2.5/site-packages/matplotlib-0.98.5.2n2-py2.5-macosx-10.3-fat.egg/matplotlib/mpl-data/fonts/ttf/Vera.ttf) with score of 0.00 enter_figure Figure(640x480) leave_figure Figure(640x480) enter_figure Figure(640x480) leave_figure Figure(640x480) enter_figure Figure(640x480) leave_figure Figure(640x480) enter_figure Figure(640x480) enter_axes Axes(0.125,0.536364;0.775x0.363636) leave_axes Axes(0.125,0.536364;0.775x0.363636) enter_axes Axes(0.125,0.1;0.775x0.363636) leave_axes Axes(0.125,0.1;0.775x0.363636) leave_figure Figure(640x480) Did not work with macosx: $HOME=/Users/darnold CONFIGDIR=/Users/darnold/.matplotlib matplotlib data path /Library/Frameworks/Python.framework/Versions/6.0.0/lib/python2.6/site-packages/matplotlib/mpl-data loaded rc file /Users/darnold/.matplotlib/matplotlibrc matplotlib version 0.99.1.1 verbose.level helpful interactive is False units is False platform is darwin Using fontManager instance from /Users/darnold/.matplotlib/fontList.cache backend MacOSX version unknown enter_axes Axes(0.125,0.536364;0.775x0.363636) leave_axes Axes(0.125,0.536364;0.775x0.363636) enter_axes Axes(0.125,0.1;0.775x0.363636) leave_axes Axes(0.125,0.1;0.775x0.363636) enter_axes Axes(0.125,0.1;0.775x0.363636) leave_axes Axes(0.125,0.1;0.775x0.363636) enter_axes Axes(0.125,0.536364;0.775x0.363636) leave_axes Axes(0.125,0.536364;0.775x0.363636) enter_axes Axes(0.125,0.1;0.775x0.363636) leave_axes Axes(0.125,0.1;0.775x0.363636) Did not work with tkagg: $HOME=/Users/darnold CONFIGDIR=/Users/darnold/.matplotlib matplotlib data path /Library/Frameworks/Python.framework/Versions/6.0.0/lib/python2.6/site-packages/matplotlib/mpl-data loaded rc file /Users/darnold/.matplotlib/matplotlibrc matplotlib version 0.99.1.1 verbose.level helpful interactive is False units is False platform is darwin Using fontManager instance from /Users/darnold/.matplotlib/fontList.cache backend TkAgg version 8.4 findfont: Matching :family=sans-serif:style=normal:variant=normal:weight=normal:stretch=normal:size=medium to Bitstream Vera Sans (/Library/Frameworks/Python.framework/Versions/4.3.0/lib/python2.5/site-packages/matplotlib-0.98.5.2n2-py2.5-macosx-10.3-fat.egg/matplotlib/mpl-data/fonts/ttf/Vera.ttf) with score of 0.00 findfont: Matching :family=sans-serif:style=normal:variant=normal:weight=normal:stretch=normal:size=12.0 to Bitstream Vera Sans (/Library/Frameworks/Python.framework/Versions/4.3.0/lib/python2.5/site-packages/matplotlib-0.98.5.2n2-py2.5-macosx-10.3-fat.egg/matplotlib/mpl-data/fonts/ttf/Vera.ttf) with score of 0.00 enter_axes Axes(0.125,0.536364;0.775x0.363636) leave_axes Axes(0.125,0.536364;0.775x0.363636) enter_axes Axes(0.125,0.1;0.775x0.363636) leave_axes Axes(0.125,0.1;0.775x0.363636) enter_axes Axes(0.125,0.536364;0.775x0.363636) leave_axes Axes(0.125,0.536364;0.775x0.363636) enter_axes Axes(0.125,0.1;0.775x0.363636) leave_axes Axes(0.125,0.1;0.775x0.363636) On Feb 14, 2010, at 7:50 PM, John Hunter wrote: > On Sun, Feb 14, 2010 at 6:53 PM, David Arnold > 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 th
[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
Re: [Matplotlib-users] Enter Figure on Macs
On Sun, Feb 14, 2010 at 6:53 PM, David Arnold 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
Re: [Matplotlib-users] memory leak for GTKAgg animation
On Sat, Feb 13, 2010 at 2:53 PM, John Jameson 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.cnt<100 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
[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] 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 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
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] turning off tick labels
On Feb 14, 2010, at 5:41 PM, Jan Strube wrote: > 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 Try this: ax.xaxis.set_major_formatter(mpl.ticker.ScalarFormatter (useOffset=False)) where 'ax' is the name of the top subplot. Good luck, Jeff -- 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
[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 <>-- 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] LineBuilder
On Sun, Feb 14, 2010 at 3:34 PM, David Arnold wrote: > line, =ax.plot([0], [0]) > plt.show() > linebuilder=LineBuilder(line) > > However, if I put the plt.show() on the last line, it works. Can anyone > explain? plt.show is meant to raise all GUI windows and start the mainloop. For many user interface toolkits it is a blocking call. The only supported use is as the last line of your script. 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
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] LineBuilder
All, I am curious why this doesn't work: # linebuilder.py import matplotlib.pyplot as plt class LineBuilder: def __init__(self, line): self.line=line self.xs=list(line.get_xdata()) self.ys=list(line.get_ydata()) self.cid=line.figure.canvas.mpl_connect('button_press_event', self) def __call__(self, event): print 'click', event if event.inaxes != self.line.axes: print event.inaxes print self.line.axes return self.xs.append(event.xdata) self.ys.append(event.ydata) self.line.set_data(self.xs, self.ys) self.line.figure.canvas.draw() fig=plt.figure() ax=fig.add_subplot(111) ax.set_title('click to build line segments') line, =ax.plot([0], [0]) plt.show() linebuilder=LineBuilder(line) However, if I put the plt.show() on the last line, it works. Can anyone explain? 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
[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] Down Another Pathway with Plot-Show (Finsihed!)
Well, well. One can get interesting results by persistence. The code I speak of here now works without using ipython. All it took was moving the offending def (show() at the end) and putting it somewhere else where the completion of the def bounced right back into the main flow of the program. The desired result was that statistics print outs to the shell now do not block the advancement of the video to the next event. All this from the single clue I offered several times. Another plot in the program that works properly. Maybe that plot and my plot break some fundamental Python law, but they both work. So far so good. Done. Now to add the individual markers to the path at key points, as per finally concluding that wild goose chase with Jae-Joon Lee a short while ago. On 2/12/2010 7:40 PM, Wayne Watson wrote: > Certainly in IDLE, when one hits a show() in a def, the program does not > continue to the next statement. It goes somewhere else, because my > program continues normally. Apparently, it goes back up the def calls to > the "main" program, which is a loop that just reads the next file to > perform more of what I expect. If I know this to be true*, that allows > a "workaround" with globals. > > * There is another def that uses plot-show, and it continues without any > notable difficulty. The show() is the last statement in the def. Of > course, since show() is a legitimate use, if one knows the "end" rule, > this seems quite reasonable way to operate. > -- "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] 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 > 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
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?
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] 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
[Matplotlib-users] Import bug for numpy >= 2.0
Lines 147-151 of __init__ need to be changed to import numpy nn = numpy.__version__.split('.') if not (int(nn[0]) > 1 or int(nn[0]) == 1 and int(nn[1]) >= 1): raise ImportError( 'numpy 1.1 or later is required; you have %s' % numpy.__version__) Chuck -- 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 > < sierra_mtnv...@sbcglobal.net > > 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] 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 wrote: > 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] Placing a marker at specific places where lines join?
On Sat, Feb 13, 2010 at 11:28 PM, Wayne Watson 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
[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?
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