You can subscribe to this list here.
| 2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(3) |
Jun
|
Jul
|
Aug
(12) |
Sep
(12) |
Oct
(56) |
Nov
(65) |
Dec
(37) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2004 |
Jan
(59) |
Feb
(78) |
Mar
(153) |
Apr
(205) |
May
(184) |
Jun
(123) |
Jul
(171) |
Aug
(156) |
Sep
(190) |
Oct
(120) |
Nov
(154) |
Dec
(223) |
| 2005 |
Jan
(184) |
Feb
(267) |
Mar
(214) |
Apr
(286) |
May
(320) |
Jun
(299) |
Jul
(348) |
Aug
(283) |
Sep
(355) |
Oct
(293) |
Nov
(232) |
Dec
(203) |
| 2006 |
Jan
(352) |
Feb
(358) |
Mar
(403) |
Apr
(313) |
May
(165) |
Jun
(281) |
Jul
(316) |
Aug
(228) |
Sep
(279) |
Oct
(243) |
Nov
(315) |
Dec
(345) |
| 2007 |
Jan
(260) |
Feb
(323) |
Mar
(340) |
Apr
(319) |
May
(290) |
Jun
(296) |
Jul
(221) |
Aug
(292) |
Sep
(242) |
Oct
(248) |
Nov
(242) |
Dec
(332) |
| 2008 |
Jan
(312) |
Feb
(359) |
Mar
(454) |
Apr
(287) |
May
(340) |
Jun
(450) |
Jul
(403) |
Aug
(324) |
Sep
(349) |
Oct
(385) |
Nov
(363) |
Dec
(437) |
| 2009 |
Jan
(500) |
Feb
(301) |
Mar
(409) |
Apr
(486) |
May
(545) |
Jun
(391) |
Jul
(518) |
Aug
(497) |
Sep
(492) |
Oct
(429) |
Nov
(357) |
Dec
(310) |
| 2010 |
Jan
(371) |
Feb
(657) |
Mar
(519) |
Apr
(432) |
May
(312) |
Jun
(416) |
Jul
(477) |
Aug
(386) |
Sep
(419) |
Oct
(435) |
Nov
(320) |
Dec
(202) |
| 2011 |
Jan
(321) |
Feb
(413) |
Mar
(299) |
Apr
(215) |
May
(284) |
Jun
(203) |
Jul
(207) |
Aug
(314) |
Sep
(321) |
Oct
(259) |
Nov
(347) |
Dec
(209) |
| 2012 |
Jan
(322) |
Feb
(414) |
Mar
(377) |
Apr
(179) |
May
(173) |
Jun
(234) |
Jul
(295) |
Aug
(239) |
Sep
(276) |
Oct
(355) |
Nov
(144) |
Dec
(108) |
| 2013 |
Jan
(170) |
Feb
(89) |
Mar
(204) |
Apr
(133) |
May
(142) |
Jun
(89) |
Jul
(160) |
Aug
(180) |
Sep
(69) |
Oct
(136) |
Nov
(83) |
Dec
(32) |
| 2014 |
Jan
(71) |
Feb
(90) |
Mar
(161) |
Apr
(117) |
May
(78) |
Jun
(94) |
Jul
(60) |
Aug
(83) |
Sep
(102) |
Oct
(132) |
Nov
(154) |
Dec
(96) |
| 2015 |
Jan
(45) |
Feb
(138) |
Mar
(176) |
Apr
(132) |
May
(119) |
Jun
(124) |
Jul
(77) |
Aug
(31) |
Sep
(34) |
Oct
(22) |
Nov
(23) |
Dec
(9) |
| 2016 |
Jan
(26) |
Feb
(17) |
Mar
(10) |
Apr
(8) |
May
(4) |
Jun
(8) |
Jul
(6) |
Aug
(5) |
Sep
(9) |
Oct
(4) |
Nov
|
Dec
|
| 2017 |
Jan
(5) |
Feb
(7) |
Mar
(1) |
Apr
(5) |
May
|
Jun
(3) |
Jul
(6) |
Aug
(1) |
Sep
|
Oct
(2) |
Nov
(1) |
Dec
|
| 2018 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2020 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2025 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| S | M | T | W | T | F | S |
|---|---|---|---|---|---|---|
|
|
|
|
1
(12) |
2
(13) |
3
(14) |
4
(9) |
|
5
(9) |
6
(22) |
7
(17) |
8
(16) |
9
(19) |
10
(17) |
11
(6) |
|
12
|
13
(20) |
14
(21) |
15
(20) |
16
(10) |
17
(14) |
18
(3) |
|
19
(3) |
20
(12) |
21
(22) |
22
(26) |
23
(31) |
24
(26) |
25
(9) |
|
26
(4) |
27
(33) |
28
(15) |
29
(37) |
30
(26) |
|
|
|
From: John S. <pra...@ho...> - 2009-04-21 23:14:43
|
I have an intel mac running os 10.4.11. I use python 2.6 I am trying to install matplotlib and I can't figure it out. Can anyone help me? _________________________________________________________________ Windows Live™ Hotmail®:…more than just e-mail. http://windowslive.com/online/hotmail?ocid=TXT_TAGLM_WL_HM_more_042009 |
|
From: Zane S. <za...@id...> - 2009-04-21 21:53:15
|
On Fri, Aug 8, 2008 at 10:35 AM, Charles R Harris
<cha...@gm...> wrote:
>
>
> On Mon, Aug 4, 2008 at 11:48 AM, Zane Selvans <za...@id...> wrote:
>>
>> Does anyone out there happen to know a simple algorithm for least
>> squares fitting a great circle to a given set of lat/lon points on a
>> sphere? Seems like it might not be a crazy thing to add to the library.
>
>
> Depends on whether you need distance along the sphere surface or not. But if
> you can deal with saggital distances it reduces to an eigenvalue problem.
> Represent the great circle by a unit vector u perpindicular to the plane
> that determined by the great circle, then minimize the sum
>
> \sum_{i=1}^{n} |dot(u,x_i)|^2
>
> which you can rewrite by setting
>
> A = \sum_{i=1}^{n} (x_i * x^T_i)
>
> so that you end up minimizing
>
> u^T * A * u
>
> subject to the constraint u^T * u = 1. The vector u is then the eigenvector
> corresponding to the smallest eigenvalue of A.
>
> Chuck
I finally ended up needing to implement great circle fitting, and went
ahead and implemented the suggestion below (yes, more than 8 months
later...). I don't think it's quite right though. The quantity to
minimize is u^T*A*u, but doing so doesn't make u one of the
eigenvectors of A, does it?
I generated a perfect great circle segment (as a series of lon,lat
points using spherical reckoning) and found its corresponding pole
(good_u) by going pi/2 radians away from it on the sphere,
perpendicular to its path.
I also converted the series of lon,lat points into x,y,z vectors (on
the unit sphere), and constructed A as:
In [552]: A = dot(array([x,y,z]),array([x,y,z]).transpose())
and then found the eigenvalues/vectors:
In [553]: eigvals_A, eigvecs_A = eig(A)
and none of them corresponds to the good_u which I found above, and
they don't minimize the product:
In [554]: [ dot(dot(eigvecs_A[N],A),eigvecs_A[N].transpose()) for N in
range(3) ]
Out[554]: [42.058431684800112, 25.787798426739176, 22.153769888460737]
whereas good_u does.
In [555]: dot(dot(good_u,A),good_u.transpose())
Out[555]: -5.9120729242764932e-15
Have I misunderstood something here? It's not immediately obvious to
me why choosing u such that it minimizes u^T * A * u would make it an
eigenvector of A. It has been a long time since I took linear algebra
though...
Thanks for any insights,
Zane
--
Zane A. Selvans
Amateur Earthling
http://zaneselvans.org
+1 303 815 6866
|
|
From: Klein, B. W. <bry...@ni...> - 2009-04-21 21:38:38
|
> Date: Tue, 21 Apr 2009 19:49:20 +0200 > From: Chaitanya Krishna <ic...@gm...> > Subject: [Matplotlib-users] Different plot settings for different > circumstances ... > > So, is there a way to decouple the plot settings (like figure size, > axes properties, tick properties, etc) from the data being plotted. If > so, can someone give some examples. > > Cheers, > Chaitanya We are using csv files (like a database) to store settings for various things and then iterating through the records to change settings for each plot and for different plot types. (line vs. scatter). For our purpose we are building a little plotting utility called 'PyroGraph' that is helping us with this task. Currently it makes about 900 plots in about 200 seconds on my computer. Under 'docs' there is a ReadMe.txt file that explains the purpose of the csv files. http://code.google.com/p/fds-smv/source/browse/trunk/FDS/trunk/Utilities/Pyr oGraph/ Also see, http://code.google.com/p/fds-smv/wiki/PyroGraph_Usage It's open source and public domain, so feel free to take whatever helps. -Bryan Klein (NIST) |
|
From: John S. <pra...@ho...> - 2009-04-21 21:24:24
|
Anyone have any help to get pylab working? Should I reinstall? What method should I use? I'm using Mac os 10.4.11. Python is included in mac os. Matplotlib I installed from a precompiled version. I tried doing what you suggest, but it didn't work. I still can't import pylab. There's also a file called libfreetype.6.3.dylib there. I don't know if that helps. > To: mat...@li... > From: jk...@ik... > Date: Mon, 20 Apr 2009 21:52:04 +0300 > Subject: Re: [Matplotlib-users] can't import pylab > > John Seales <pra...@ho...> writes: > > > it's a problem with ft2font. I checked for the existence of the files > > it's looking for, the libfreetype.6.dylib, and ft2font.so – they exist > > in the places they're supposed to. I don't really know what 'image not > > found' exactly means. > > > ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/ft2font.so, 2): Library not loaded: /usr/X11R6/lib/libfreetype.6.dylib > > Referenced from: /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/ft2font.so > > Reason: image not found > > What version of OS X are you using? How did you install Python and > Matplotlib - did you get a precompiled version, or install via Fink or > MacPorts, or compile it yourself? > > Here's a wild guess: since /usr/X11R6 is just a symlink to /usr/X11, the > file /usr/X11R6/lib/libfreetype.6.dylib has an "install name" of > /usr/X11/lib/libfreetype.6.dylib, and perhaps the dynamic linker doesn't > like the mismatch. Do the following commands fix the problem? > > cd /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib > cp ft2font.so ft2font.so.bak > install_name_tool -change /usr/X11R6/lib/libfreetype.6.dylib \ > /usr/X11/lib/libfreetype.6.dylib ft2font.so > > If not, copy ft2font.so.bak back over the modified ft2font.so to prevent > the attempted fix from breaking anything else. > > -- > Jouni K. Seppänen > http://www.iki.fi/jks > > > ------------------------------------------------------------------------------ > Stay on top of everything new and different, both inside and > around Java (TM) technology - register by April 22, and save > $200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco. > 300 plus technical and hands-on sessions. Register today. > Use priority code J9JMT32. http://p.sf.net/sfu/p > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users Rediscover Hotmail®: Get quick friend updates right in your inbox. Check it out. _________________________________________________________________ Rediscover Hotmail®: Now available on your iPhone or BlackBerry http://windowslive.com/RediscoverHotmail?ocid=TXT_TAGLM_WL_HM_Rediscover_Mobile2_042009 |
|
From: Thomas R. <tho...@gm...> - 2009-04-21 18:53:58
|
Hello,
I am having a problem with imshow and PNG output. The following code
can reproduce the problem:
---
import matplotlib
matplotlib.use('Agg')
from matplotlib.pyplot import *
import numpy as np
image = np.random.random((100,100))
fig = figure(figsize=(4,4))
ax = fig.add_subplot(111)
ax.imshow(image,interpolation='nearest')
fig.savefig('plot.png',dpi=150)
---
If you zoom in to the top of the box, you can see the image poking out
of the axes. The effect isn't obvious in this image at normal zoom,
but I've seen cases where it is more obvious, for example if the image
is quite dark and a white frame is being used, in which case it can
look messy.
Is this a bug with the clipping?
Thanks,
Thomas
|
|
From: Thomas R. <tho...@gm...> - 2009-04-21 18:44:26
|
Thanks for your quick reply! I'll be patient and wait for the fix to be made in the SVN repository, rather than trying to patch it myself. Do I need to add any information to the bug report? Best, Thomas On Apr 21, 2009, at 1:06 PM, Jae-Joon Lee wrote: > I can reproduce this bug with the current svn. > > It works correctly If you set dpi=72, but it seems that it would not > be an option in your case. > > It seems to me that this is related with the change in r6847 that > Michael made. > > http://matplotlib.svn.sourceforge.net/viewvc/matplotlib/trunk/matplotlib/lib/matplotlib/backends/backend_ps.py?r1=6734&r2=6847 > > At line 431 of the backend_ps.py, > > clip = (0.0, 0.0, self.width * self.imagedpi, > self.height * self.imagedpi) > > I think we should use the dpi of the figure, instead of the imagedpi > of the renderer. > Replacing self.imagedpi with 72 (which is the dpi of the figure when > ps backend is used) seems to solve the problem. > > Thomas, I don't see any easy workaround for this bug other than > patching the code. Others may have better insight though. > > Regards, > > -JJ > > > > On Tue, Apr 21, 2009 at 9:59 AM, Thomas Robitaille > <tho...@gm...> wrote: >> Hi, >> >> I've come across a bug with the savefig method when using the dpi= >> argument and saving an EPS file. If you try the following code, you >> will see that the frame is incomplete. Is there a way to solve this >> from a user point of view? >> >> --- >> >> import matplotlib >> matplotlib.use('Agg') >> from matplotlib.pyplot import * >> >> import numpy as np >> >> nx,ny = 10,10 >> >> image = np.random.random((nx,ny)) >> >> fig = figure(figsize=(4,4)) >> ax = fig.add_subplot(111) >> ax.imshow(image,interpolation='nearest') >> fig.savefig('plot.eps',dpi=30) >> >> --- >> >> I've submitted a bug report: >> >> https://sourceforge.net/tracker/?func=detail&aid=2777476&group_id=80706&atid=560720 >> >> Thanks, >> >> Thomas >> >> ------------------------------------------------------------------------------ >> Stay on top of everything new and different, both inside and >> around Java (TM) technology - register by April 22, and save >> $200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco. >> 300 plus technical and hands-on sessions. Register today. >> Use priority code J9JMT32. http://p.sf.net/sfu/p >> _______________________________________________ >> Matplotlib-users mailing list >> Mat...@li... >> https://lists.sourceforge.net/lists/listinfo/matplotlib-users >> |
|
From: Alan G I. <ala...@gm...> - 2009-04-21 18:39:42
|
Other projects than can profit if this is thought through: - docutils (e.g., the rst2mathml writer) - plasTeX (which additionally should have many good ideas to share) Alan Isaac |
|
From: Tony S Yu <to...@MI...> - 2009-04-21 18:19:05
|
On Apr 21, 2009, at 1:49 PM, Chaitanya Krishna wrote: > But, anyways the point of this mail is to ask if there is a clever way > of making different plots for different circumstances. For example, > trying to make a plot for publication in a journal demands it being > made in one way while using it in a presentation demands you to make a > different one and probably trying to use it in a report requires > another one. > > So, is there a way to decouple the plot settings (like figure size, > axes properties, tick properties, etc) from the data being plotted. If > so, can someone give some examples. Here's another example from the matplotlib docs that sounds more like what you're looking for: http://matplotlib.sourceforge.net/examples/pylab_examples/customize_rc.html?highlight=set_pub I use something similar to the ``set_pub`` method in the comments of the example. I have a module ``plotstyle`` which has methods for ``presentation``, ``publication``, etc. and whenever I want a script to use a certain style I just add: >>> import plotstyle >>> plotstyle.presention() Best, -Tony |
|
From: projetmbc <pro...@cl...> - 2009-04-21 18:16:28
|
That's could be "cool" but this needs to have access to the size of the final picture of the formula and the location of the baseline of the text. With this, it's easy to put formulas in a web page. Christophe. > Are there already any more concrete ideas on how this will be realised > technically, in particular how this engine will be callable from > Python programs? |
|
From: Alan G I. <ala...@gm...> - 2009-04-21 18:04:21
|
On 4/21/2009 1:49 PM Chaitanya Krishna apparently wrote: > So, is there a way to decouple the plot settings (like figure size, > axes properties, tick properties, etc) from the data being plotted. If > so, can someone give some examples. http://matplotlib.sourceforge.net/users/customizing.html hth, Alan Isaac |
|
From: Chaitanya K. <ic...@gm...> - 2009-04-21 17:49:47
|
Hi guys, I generally use matplotlib it extract information from raw data and use this for plotting. I wonder what most of you guys out there use it for? But, anyways the point of this mail is to ask if there is a clever way of making different plots for different circumstances. For example, trying to make a plot for publication in a journal demands it being made in one way while using it in a presentation demands you to make a different one and probably trying to use it in a report requires another one. So, is there a way to decouple the plot settings (like figure size, axes properties, tick properties, etc) from the data being plotted. If so, can someone give some examples. Cheers, Chaitanya |
|
From: Gökhan S. <gok...@gm...> - 2009-04-21 17:44:40
|
Hi Matthias, Thanks for your reply again. Unfortunately I can't read x_new or y_new after I kill the figures (nor when they are active). I don't know what exactly wrong in my configuration or IPython. I use IPython 0.10.bzr.r1163 on Fedora 10. Hopefully, I will solve the masked array riddle by reading more (although haven't seen a specific example similar to my question on the numpy reference pages), if not getting some insight from a numpy expert or like you said from an expert on masked arrays :) Have a good Tuesday to all. Gökhan On Tue, Apr 21, 2009 at 3:21 AM, Matthias Michler <Mat...@gm...>wrote: > Hi Gökhan, > Hi list, > Hi experts on masked arrays, > > I run the attached script (copied from your last two emails) and I can use > x_new, y_new after closing the figures (where x_new and y_new are the > values > selected in the last selection). > > I don't know, what is going wrong with your script on your system. > > ### my output ########################## > In [1]: run rect.py > startposition : (0.276210, 0.592969) > endposition : (0.542339, 0.309375) > used button : 1 > startposition : (0.745968, 0.747656) > endposition : (0.745968, 0.747656) > used button : 1 > startposition : (0.645161, 0.761719) > endposition : (0.806452, 0.609375) > used button : 3 > startposition : (0.808468, 0.607031) > endposition : (0.808468, 0.604688) > used button : 3 > startposition : (0.086694, 0.166406) > endposition : (0.137097, 0.070313) > used button : 1 > startposition : (0.921371, 0.850781) > endposition : (0.987903, 0.728906) > used button : 1 > > In [2]: x_new > Out[2]: > array([ 0.92929293, 0.93939394, 0.94949495, 0.95959596, 0.96969697, > 0.97979798]) > > In [3]: y_new > Out[3]: > array([ 0.80119703, 0.8072005 , 0.81312162, 0.81895978, 0.82471437, > 0.83038482]) > > In [4]: > ############# > > Please see my comments below. > > On Monday 20 April 2009 23:16:37 Gökhan SEVER wrote: > > Thanks for elegant trick Matthias. > > > > I have modified onselect function following your suggestions, and it is > > working as I wanted it to be. Select a portion and get a zoomed view in a > > new figure. > > > > def onselect(eclick, erelease): > > # eclick and erelease are matplotlib events at press and release > > global x_new > > global y_new > > print ' startposition : (%f, %f)' % (eclick.xdata, eclick.ydata) > > print ' endposition : (%f, %f)' % (erelease.xdata, erelease.ydata) > > print ' used button : ', eclick.button > > xmin = min(eclick.xdata, erelease.xdata) > > xmax = max(eclick.xdata, erelease.xdata) > > ymin = min(eclick.ydata, erelease.ydata) > > ymax = max(eclick.ydata, erelease.ydata) > > indices = (x >= xmin) & (x <= xmax) & (y >= ymin) & (y <= ymax) > > x_new = x[indices] > > y_new = y[indices] > > fig_new = figure() > > plot(x_new, y_new) > > fig_new.show() > > > > There is still a minute point, that I would like mention again. Even > though > > I used global style variables I can't still see them when I quit the > > program. > > > > What I do is run the file within IPython by run command. In my case the > > file is 'rect.py.' and I do run rect.py. When I quit and do whos querry, > I > > can't see global x_new nor y_new at the resulting lines: > > > > In [13]: whos > > Variable Type Data/Info > > -------------------------------------------- > > RectangleSelector classobj matplotlib.widgets.RectangleSelector > > ax AxesSubplot Axes(0.125,0.1;0.775x0.8) > > fig function <function figure at 0xa752c6c> > > onselect function <function onselect at 0xac0ec34> > > toggle_selector function <function toggle_selector at > 0xac0ef0c> > > x ndarray 100: 100 elems, type `float64`, 800 > > bytes y ndarray 100: 100 elems, type `float64`, > > 800 bytes > > > > > > For the masking, I was planning to use a masking scheme as given below. > Let > > say I have an array which "a" > > > > In [14]: a = arange(5) > > > > In [15]: a > > Out[15]: array([0, 1, 2, 3, 4]) > > > > and my secondary array is "b" > > > > In [16]: b = array([2,3]) > > > > What I want to do is to mask a with b values and get an array of: > > > > [array([False, False, True, True, False], dtype=bool)] > > > > That is just an manually created array. I still don't know how to do this > > programmatically in Pythonic fashion. > > As I mentioned before I'm not familiar with numpys masked arrays. In this > list > I read several comments on them, but I never used them. But I think they > are > what you are after. Maybe someone else can give you a hint or you try > numpys > online documentation. > All I could provide is again a little manually work using a for-loop. So > something like > > mask = zeros(len(a), dtype=bool) > for index in xrange(len(a)): # run through array a > if a[index] in b: > mask[index] = True > print mask # gives array([False, False, True, True, False], > dtype=bool) > > Furthermore I'm not a Python expert and therefore I'm not the guy to ask > for > programing in "Pythonic fashion". Maybe some else can give a comment? > > best regards Matthias > > > Again thanks for your help. > > > > Gökhan > > > > > > On Mon, Apr 20, 2009 at 4:09 AM, Matthias Michler > > > > <Mat...@gm...>wrote: > > > Hi Gökhan, > > > > > > On Friday 17 April 2009 20:21:00 Gökhan SEVER wrote: > > > > Thanks for the pointer Matthias, > > > > > > > > That is exactly what I have been looking for. > > > > > > > > I use the code from the RectangleSelector class help with your > > > > suggested code. I know that I have to update y-axis accordingly to x > > > > values such > > > > > > that > > > > > > > their positions and sizes must much so that I can plot them in a new > > > > > > plot. > > > > > > > And I know that the answer lies in a mask; I have to create a mask > from > > > > x_new and apply it to y. Do you have any hint on this? > > > > > > Unfortunately I'm not familiar with numpy masks, but what I would do > is: > > > > > > xmin = min(eclick.xdata, erelease.xdata) > > > xmax = max(eclick.xdata, erelease.xdata) > > > ymin = min(eclick.ydata, erelease.ydata) > > > ymax = max(eclick.ydata, erelease.ydata) > > > # indices inside x-range > > > indices = (x>= xmin) & (x <= xmax) > > > # OR: indices for data inside the selected rectangle > > > #indices = (x>= xmin) & (x <= xmax) & (y>=ymin) & (y<=ymax) > > > xnew = x[indices] > > > ynew = y[indices] > > > > > > > Another point is do you have any idea how to save values from inside > > > > onselect action? > > > > > > What do you mean by saving? > > > Saving to disk? > > > # for ascii format I use: > > > from scipy.io import write_array > > > > > > # for numpy arrays you can use > > > import numpy as np > > > a = np.arange(10) > > > a.tofile # Write array to a file as text or binary. > > > > > > and I think there is also some Matplotlib function for this. In the > > > module matplotlib.mlab, which also allows reading different types of > > > formatted data. > > > > > > If you think of saving inside the program. You need a global variable > > > (statement "global x" at the beginning of onselect) otherwise all > > > variables are deleted at the end of each onselect call. > > > > > > > For some reason my ipython session doesn't remember values after I > run > > > > > > the > > > > > > > given script: > > > > > > see three lines above, please. > > > > > > best regards Matthias > > > > > > > from matplotlib.widgets import RectangleSelector > > > > from pylab import * > > > > > > > > def onselect(eclick, erelease): > > > > # eclick and erelease are matplotlib events at press and release > > > > print ' startposition : (%f, %f)' % (eclick.xdata, eclick.ydata) > > > > print ' endposition : (%f, %f)' % (erelease.xdata, > > > > erelease.ydata) print ' used button : ', eclick.button > > > > xmin = min(eclick.xdata, erelease.xdata) > > > > xmax = max(eclick.xdata, erelease.xdata) > > > > ymin = min(eclick.ydata, erelease.ydata) > > > > ymax = max(eclick.ydata, erelease.ydata) > > > > x_new = x[(x>= xmin) & (x <= xmax)] > > > > #mask = [x == x_new[i] for i in range(len(x_new))] > > > > #print mask > > > > #print len(x_new) > > > > #print len(y_new) > > > > #fig_new = figure() > > > > #plot(x_new, y_new) > > > > #fig_new.show() > > > > > > > > def toggle_selector(event): > > > > print ' Key pressed.' > > > > if event.key in ['Q', 'q'] and toggle_selector.RS.active: > > > > print ' RectangleSelector deactivated.' > > > > toggle_selector.RS.set_active(False) > > > > if event.key in ['A', 'a'] and not toggle_selector.RS.active: > > > > print ' RectangleSelector activated.' > > > > toggle_selector.RS.set_active(True) > > > > > > > > x = arange(100)/(99.0) > > > > y = sin(x) > > > > fig = figure > > > > ax = subplot(111) > > > > ax.plot(x,y) > > > > > > > > toggle_selector.RS = RectangleSelector(ax, onselect, drawtype='box') > > > > connect('key_press_event', toggle_selector) > > > > show() > > > > > > > > Gökhan > > > > > > > > > > > > On Fri, Apr 17, 2009 at 2:31 AM, Matthias Michler > > > > > > > > <Mat...@gm...>wrote: > > > > > Hi Gökhan, > > > > > > > > > > I recommend you to use matplotlib.widgets.RectangleSelector instead > > > > > of the zoom functionality to select the data (An example can be > found > > > > > at > > > > > > > http://matplotlib.sourceforge.net/examples/widgets/rectangle_selector.htm > > > > > > > >l). This will return you the x and y-coordinate of button press and > > > > > > button > > > > > > > > release > > > > > event and with that you can take a portion of your data. > > > > > Something like the following could be a starting point: > > > > > x_min = min(eclick.xdata, erelease.xdata) > > > > > x_max = max(eclick.xdata, erelease.xdata) > > > > > x_new = x[(x>= x_min) & (x <= x_max)] > > > > > > > > > > where eclick and erelease correspond to the click and release event > > > > > of the rectangle selection (see the example below). > > > > > > > > > > Opening a new figure after show can be achieved by: > > > > > > > > > > fig_new = plt.figure() > > > > > # some plotting > > > > > fig_new.show() # show up the new figure > > > > > > > > > > > > > > > best regards Matthias > > > > > > > > > > > > > > > yet another example for the usage of the RectangleSelector copied > > > > > from its class documentation: > > > > > > > > > > """ > > > > > Select a min/max range of the x axes for a matplotlib Axes > > > > > > > > > > Example usage:: > > > > > > > > > > from matplotlib.widgets import RectangleSelector > > > > > from pylab import * > > > > > > > > > > def onselect(eclick, erelease): > > > > > 'eclick and erelease are matplotlib events at press and > > > > > > release' > > > > > > > > print ' startposition : (%f, %f)' % (eclick.xdata, > > > > > > eclick.ydata) > > > > > > > > print ' endposition : (%f, %f)' % (erelease.xdata, > > > > > erelease.ydata) > > > > > print ' used button : ', eclick.button > > > > > > > > > > def toggle_selector(event): > > > > > print ' Key pressed.' > > > > > if event.key in ['Q', 'q'] and > toggle_selector.RS.active: > > > > > print ' RectangleSelector deactivated.' > > > > > toggle_selector.RS.set_active(False) > > > > > if event.key in ['A', 'a'] and not > > > > > > toggle_selector.RS.active: > > > > > print ' RectangleSelector activated.' > > > > > toggle_selector.RS.set_active(True) > > > > > > > > > > x = arange(100)/(99.0) > > > > > y = sin(x) > > > > > fig = figure > > > > > ax = subplot(111) > > > > > ax.plot(x,y) > > > > > > > > > > toggle_selector.RS = RectangleSelector(ax, onselect, > > > > > drawtype='line') > > > > > connect('key_press_event', toggle_selector) > > > > > show() > > > > > """ > > > > > > > > > > On Friday 17 April 2009 02:26:51 Gökhan SEVER wrote: > > > > > > Hello, > > > > > > > > > > > > A quick question: > > > > > > > > > > > > I am using two numpy arrays to plot the figure shown in > attachment. > > > > > > Is > > > > > > > > > it possible to get array indices of selected X-axes while using > the > > > > > > zoom function? Later I can create a new figure from this selected > > > > > > portion instead of the same figure and/or apply an analysis. > > > > > > > > > > > > Thank you. > > > > > > > ------------------------------------------------------------------------- > > > > > > > >----- Stay on top of everything new and different, both inside and > > > > > around Java (TM) technology - register by April 22, and save > > > > > $200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco. > > > > > 300 plus technical and hands-on sessions. Register today. > > > > > Use priority code J9JMT32. http://p.sf.net/sfu/p > > > > > _______________________________________________ > > > > > Matplotlib-users mailing list > > > > > Mat...@li... > > > > > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > > > > > > ------------------------------------------------------------------------- > > >----- Stay on top of everything new and different, both inside and > > > around Java (TM) technology - register by April 22, and save > > > $200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco. > > > 300 plus technical and hands-on sessions. Register today. > > > Use priority code J9JMT32. http://p.sf.net/sfu/p > > > _______________________________________________ > > > Matplotlib-users mailing list > > > Mat...@li... > > > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > > > > ------------------------------------------------------------------------------ > Stay on top of everything new and different, both inside and > around Java (TM) technology - register by April 22, and save > $200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco. > 300 plus technical and hands-on sessions. Register today. > Use priority code J9JMT32. http://p.sf.net/sfu/p > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > |
|
From: Kasper P. <kas...@ae...> - 2009-04-21 17:11:34
|
Hi all, I noticed that a Google Summer of Code project has been allocated for extraction of the TeX rendering engine of matplotlib. Excellent! Are there already any more concrete ideas on how this will be realised technically, in particular how this engine will be callable from Python programs? Will it be bound to e.g. PyGtk or some other low-level graphics library? And is there perhaps a plan to make this usable also from other languages? (I am thinking concretely about C++ for my own needs, but can very well imagine that this would be extremely useful also in other languages; something like a 'glib for TeX, plus language wrappers' would be ideal). Best, Kasper |
|
From: Jae-Joon L. <lee...@gm...> - 2009-04-21 17:06:58
|
I can reproduce this bug with the current svn. It works correctly If you set dpi=72, but it seems that it would not be an option in your case. It seems to me that this is related with the change in r6847 that Michael made. http://matplotlib.svn.sourceforge.net/viewvc/matplotlib/trunk/matplotlib/lib/matplotlib/backends/backend_ps.py?r1=6734&r2=6847 At line 431 of the backend_ps.py, clip = (0.0, 0.0, self.width * self.imagedpi, self.height * self.imagedpi) I think we should use the dpi of the figure, instead of the imagedpi of the renderer. Replacing self.imagedpi with 72 (which is the dpi of the figure when ps backend is used) seems to solve the problem. Thomas, I don't see any easy workaround for this bug other than patching the code. Others may have better insight though. Regards, -JJ On Tue, Apr 21, 2009 at 9:59 AM, Thomas Robitaille <tho...@gm...> wrote: > Hi, > > I've come across a bug with the savefig method when using the dpi= > argument and saving an EPS file. If you try the following code, you > will see that the frame is incomplete. Is there a way to solve this > from a user point of view? > > --- > > import matplotlib > matplotlib.use('Agg') > from matplotlib.pyplot import * > > import numpy as np > > nx,ny = 10,10 > > image = np.random.random((nx,ny)) > > fig = figure(figsize=(4,4)) > ax = fig.add_subplot(111) > ax.imshow(image,interpolation='nearest') > fig.savefig('plot.eps',dpi=30) > > --- > > I've submitted a bug report: > > https://sourceforge.net/tracker/?func=detail&aid=2777476&group_id=80706&atid=560720 > > Thanks, > > Thomas > > ------------------------------------------------------------------------------ > Stay on top of everything new and different, both inside and > around Java (TM) technology - register by April 22, and save > $200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco. > 300 plus technical and hands-on sessions. Register today. > Use priority code J9JMT32. http://p.sf.net/sfu/p > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > |
|
From: Thomas R. <tho...@gm...> - 2009-04-21 13:59:18
|
Hi,
I've come across a bug with the savefig method when using the dpi=
argument and saving an EPS file. If you try the following code, you
will see that the frame is incomplete. Is there a way to solve this
from a user point of view?
---
import matplotlib
matplotlib.use('Agg')
from matplotlib.pyplot import *
import numpy as np
nx,ny = 10,10
image = np.random.random((nx,ny))
fig = figure(figsize=(4,4))
ax = fig.add_subplot(111)
ax.imshow(image,interpolation='nearest')
fig.savefig('plot.eps',dpi=30)
---
I've submitted a bug report:
https://sourceforge.net/tracker/?func=detail&aid=2777476&group_id=80706&atid=560720
Thanks,
Thomas
|
|
From: Armin M. <arm...@st...> - 2009-04-21 11:40:34
|
Hi,
i have an application showing some pseudo color plots as images using
imshow. After deleting an image and calling ax.axis('tight') the limits
of the axes are not updated correctly. Is this a bug, incorrect use or
intended? The behavior is demonstrated in the appended script.
Best regards,
Armin
-----8<-----------------
#!/usr/bin/env python
from pylab import *
a = rand(5,5)
ax = axes()
ax.imshow(a,extent=(0,5,0,5))
ax.imshow(a,extent=(5,10,5,10))
ax.axis('tight')
waitforbuttonpress()
ax.images.pop(0)
ax.axis('tight')
show()
-----8<-----------------
|
|
From: Jouni K. S. <jk...@ik...> - 2009-04-21 07:10:35
|
John Seales <pra...@ho...> writes: > I'm using Mac os 10.4.11. Python is included in mac os. The error messages refer to Python 2.6: >> > ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/ft2font.so, 2): Library not loaded: /usr/X11R6/lib/libfreetype.6.dylib >> > Referenced from: /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/ft2font.so If you are somehow using this with the system Python, it's no wonder that you are having problems. I think OS X 10.4 includes Python 2.3 or at most 2.4 - version 10.5 has Python 2.5. But perhaps you have installed some other version of Python - one way to test what you are using is to look at where Python gets its modules: ~% python Python 2.5.2 (r252:60911, Feb 22 2008, 07:57:53) [GCC 4.0.1 (Apple Computer, Inc. build 5363)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import os >>> os <module 'os' from '/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/os.pyc'> (So I am using something else than the system-supplied Python, whose os.pyc file is under /System/Library.) Some distributions of Python for OS X are mentioned here: http://matplotlib.sourceforge.net/faq/installing_faq.html#which-python-for-osx > Matplotlib I installed from a precompiled version. Is this the version from Sourceforge, or somewhere else? Anyway, the library linking problems sound a lot like you are using software that was not compiled for your version of OS X - I guess most developers have upgraded to Leopard quite some time ago, so they would not notice if something breaks on older releases. The larger question is, which versions of OS X should be supported by the binary packages? The ReadMe.txt bundled with the MacPython 2.6.2 installer says: This package will install MacPython 2.6.2 for Mac OS X 10.3 or later for the following architecture(s): i386, ppc. So Python itself supports Panther and newer, and I think the compiler flags used by Python are inherited by extensions - but if there is something other than just compiler flags to worry about, someone would have to have an installation of the target version of OS X to test on. -- Jouni K. Seppänen http://www.iki.fi/jks |
|
From: Carlos G. G. <car...@gm...> - 2009-04-21 03:11:02
|
Dears, I'm trying to change the labels of a polar plot I have inside a
wxpython app, but keep getting errors...
this is a snippet of the code:
#class for the second page of the notebook
class PlotPanel(wx.Panel):
def __init__(self, parent):
wx.Panel.__init__(self, parent)
box1 = wx.BoxSizer(wx.VERTICAL)
st1 = wx.StaticText(self, -1, 'Plot')
box1.Add(st1, 0, wx.RIGHT, 8)
box3 = wx.BoxSizer(wx.VERTICAL)
self.figure = Figure(figsize=(6,6))#
self.canvas = FigureCanvas(self, -1, self.figure)
self.axes = self.figure.add_axes([0.1, 0.1, 0.8, 0.8],projection='polar')
pylab.thetagrids( range(0,360,45), ('E', 'NE', 'N','NW', 'W', 'SW',
'S', 'SE') )
box3.Add(self.canvas, 1, wx.LEFT|wx.TOP|wx.GROW)
box1.Add(box3,1, wx.EXPAND)
self.SetSizer(box1)
and these are the error msgs:
python pystereo12.py
Traceback (most recent call last):
File "pystereo12.py", line 184, in <module>
app=pystereo()
File "/usr/lib/python2.5/site-packages/wx-2.8-gtk2-unicode/wx/_core.py",
line 7912, in __init__
self._BootstrapApp()
File "/usr/lib/python2.5/site-packages/wx-2.8-gtk2-unicode/wx/_core.py",
line 7487, in _BootstrapApp
return _core_.PyApp__BootstrapApp(*args, **kwargs)
File "pystereo12.py", line 179, in OnInit
self.frame=MyFrame(None, -1, 'PyStereo', size=(800,600))
File "pystereo12.py", line 120, in __init__
self.right_panel = PlotPanel(splitter) # right panel, where stats are shown
File "pystereo12.py", line 70, in __init__
pylab.thetagrids( range(0,360,45), ('E', 'NE', 'N','NW', 'W',
'SW', 'S', 'SE') )
File "/usr/lib/python2.5/site-packages/matplotlib/pyplot.py", line
1092, in thetagrids
raise RuntimeError('rgrids only defined for polar axes')
RuntimeError: rgrids only defined for polar axes
TIA
Carlos
--
Carlos Henrique Grohmann - Geologist D.Sc.
a.k.a. Guano - Linux User #89721
ResearcherID: A-9030-2008
carlos dot grohmann at gmail dot com
http://www.igc.usp.br/pessoais/guano/
_________________
"Good morning, doctors. I have taken the liberty of removing Windows
95 from my hard drive."
--The winning entry in a "What were HAL's first words" contest judged
by 2001: A SPACE ODYSSEY creator Arthur C. Clarke
Can’t stop the signal.
|
|
From: Eric F. <ef...@ha...> - 2009-04-21 02:41:37
|
Gökhan SEVER wrote: > Eric, > > I see many quality descriptive plots and analysis results following the > main currents page. Really a professional looking research job. Could > you please tell me how many people working on this project and how long > have you been working on it? We are way off topic here, so I will end this thread to the list and reply to you individually. Eric |
|
From: Gökhan S. <gok...@gm...> - 2009-04-21 01:43:05
|
Eric, I see many quality descriptive plots and analysis results following the main currents page. Really a professional looking research job. Could you please tell me how many people working on this project and how long have you been working on it? Thank you Gökhan On Mon, Apr 20, 2009 at 5:18 PM, Eric Firing <ef...@ha...> wrote: > Gökhan SEVER wrote: > >> Eric, >> >> As you said, your program features more than what me in my mind. It looks >> very cool. There are some parts which I don't understand quite well. >> >> I will definitely save it for my future programming adventures. I will >> solely use it in my academical research, since I am a graduate student >> working on atmospheric sciences. >> >> I like the Mercurial repository of the project, and the way it is >> presented. I am planning establish something similar to yours. So in the >> future I might have some more questions to you. >> >> By the way, could please tell me more what does pycurrents do? I can guess >> a little from its name. Actually for the next year I have a plan of >> implementing a design named pyclouds for simple cloud simulation and/or >> modelling. >> >> Gökhan >> > > Gökhan, > > pycurrents is simply a name for one of several repos into which we have > divided our code; it is for python code that we use for our work in physical > oceanography, with a heavy weighting toward processing acoustic Doppler > current profiler (ADCP) data. It is a catch-all. It includes good stuff, > work in progress (to some extent that description applies to everything), > and some things that are obsolete and/or first tries still waiting to be > rewritten. For context, see http://currents.soest.hawaii.edu/. > > Eric > |
|
From: Eric F. <ef...@ha...> - 2009-04-20 22:18:35
|
Gökhan SEVER wrote: > Eric, > > As you said, your program features more than what me in my mind. It > looks very cool. There are some parts which I don't understand quite well. > > I will definitely save it for my future programming adventures. I will > solely use it in my academical research, since I am a graduate student > working on atmospheric sciences. > > I like the Mercurial repository of the project, and the way it is > presented. I am planning establish something similar to yours. So in the > future I might have some more questions to you. > > By the way, could please tell me more what does pycurrents do? I can > guess a little from its name. Actually for the next year I have a plan > of implementing a design named pyclouds for simple cloud simulation > and/or modelling. > > Gökhan Gökhan, pycurrents is simply a name for one of several repos into which we have divided our code; it is for python code that we use for our work in physical oceanography, with a heavy weighting toward processing acoustic Doppler current profiler (ADCP) data. It is a catch-all. It includes good stuff, work in progress (to some extent that description applies to everything), and some things that are obsolete and/or first tries still waiting to be rewritten. For context, see http://currents.soest.hawaii.edu/. Eric |
|
From: Elan P. <el...@MI...> - 2009-04-20 21:50:52
|
Hi, I'm trying to use matplotlib for animating data as it is received from an online source (online in the algorithmic sense not internet:). I'd like the graph plot to be updated with high frequency since the data changes rapidly. I've used the BufferRegion with copy_from_bbox / restore_region and it speeds up the plotting considerably but alas it's still not good enough (with a large number of graphs and a large number of data points in each graph). What I'd like to do is to utilize the fact that the animation is updated in a predictable fashion (i.e., scrolling off the screen to the left as new data arrives) in order to speed up the animation. The idea would be to copy the right 99% of the graph (or some other fraction) via some kind of function similar to copy_from_bbox, move it 1% to the left and then plot the new 1% of the data. The problem is that as far as I can tell the copy_from_bbox/restore_region does not actually allow changing the area in which it is restored. I've mucked around in the source files a bit but to no avail. My question is then: 1. Is there some other way to copy everything enclosed in a Bbox? or 2. Is there some way to modify the region in which data reappears when using restore_region? 3. Perhaps I'm missing something? I'm sure someone else has done this since it seems pretty natural and useful for a variety of applications. Elan ---- "If stupidity got us into this mess, why can't it get us out?" - Will Rogers |
|
From: Gökhan S. <gok...@gm...> - 2009-04-20 21:22:36
|
Eric, As you said, your program features more than what me in my mind. It looks very cool. There are some parts which I don't understand quite well. I will definitely save it for my future programming adventures. I will solely use it in my academical research, since I am a graduate student working on atmospheric sciences. I like the Mercurial repository of the project, and the way it is presented. I am planning establish something similar to yours. So in the future I might have some more questions to you. By the way, could please tell me more what does pycurrents do? I can guess a little from its name. Actually for the next year I have a plan of implementing a design named pyclouds for simple cloud simulation and/or modelling. Gökhan On Mon, Apr 20, 2009 at 1:29 PM, Eric Firing <ef...@ha...> wrote: > Matthias Michler wrote: > > Hi Gökhan, > > > > On Friday 17 April 2009 20:21:00 Gökhan SEVER wrote: > >> Thanks for the pointer Matthias, > >> > >> That is exactly what I have been looking for. > > You might also find useful ideas here: > > > http://currents.soest.hawaii.edu/hg/hgwebdir.cgi/pycurrents/file/2ec7845a90c3/plot/txyzoom.py#l1 > > I haven't followed this thread closely, but my impression is that what > you are trying to do is similar to, but perhaps simpler than, what is > done by txyzoom.py. > > I don't have license info in the file or repo yet, but consider it > available under a matplotlib-style license. > > Eric > > >> > >> I use the code from the RectangleSelector class help with your suggested > >> code. I know that I have to update y-axis accordingly to x values such > that > >> their positions and sizes must much so that I can plot them in a new > plot. > >> And I know that the answer lies in a mask; I have to create a mask from > >> x_new and apply it to y. Do you have any hint on this? > > > > Unfortunately I'm not familiar with numpy masks, but what I would do is: > > > > xmin = min(eclick.xdata, erelease.xdata) > > xmax = max(eclick.xdata, erelease.xdata) > > ymin = min(eclick.ydata, erelease.ydata) > > ymax = max(eclick.ydata, erelease.ydata) > > # indices inside x-range > > indices = (x>= xmin) & (x <= xmax) > > # OR: indices for data inside the selected rectangle > > #indices = (x>= xmin) & (x <= xmax) & (y>=ymin) & (y<=ymax) > > xnew = x[indices] > > ynew = y[indices] > > > >> Another point is do you have any idea how to save values from inside > >> onselect action? > > > > What do you mean by saving? > > Saving to disk? > > # for ascii format I use: > > from scipy.io import write_array > > > > # for numpy arrays you can use > > import numpy as np > > a = np.arange(10) > > a.tofile # Write array to a file as text or binary. > > > > and I think there is also some Matplotlib function for this. In the > module > > matplotlib.mlab, which also allows reading different types of formatted > data. > > > > If you think of saving inside the program. You need a global variable > > (statement "global x" at the beginning of onselect) otherwise all > variables > > are deleted at the end of each onselect call. > > > >> For some reason my ipython session doesn't remember values after I run > the > >> given script: > > > > see three lines above, please. > > > > best regards Matthias > >> from matplotlib.widgets import RectangleSelector > >> from pylab import * > >> > >> def onselect(eclick, erelease): > >> # eclick and erelease are matplotlib events at press and release > >> print ' startposition : (%f, %f)' % (eclick.xdata, eclick.ydata) > >> print ' endposition : (%f, %f)' % (erelease.xdata, erelease.ydata) > >> print ' used button : ', eclick.button > >> xmin = min(eclick.xdata, erelease.xdata) > >> xmax = max(eclick.xdata, erelease.xdata) > >> ymin = min(eclick.ydata, erelease.ydata) > >> ymax = max(eclick.ydata, erelease.ydata) > >> x_new = x[(x>= xmin) & (x <= xmax)] > >> #mask = [x == x_new[i] for i in range(len(x_new))] > >> #print mask > >> #print len(x_new) > >> #print len(y_new) > >> #fig_new = figure() > >> #plot(x_new, y_new) > >> #fig_new.show() > >> > >> def toggle_selector(event): > >> print ' Key pressed.' > >> if event.key in ['Q', 'q'] and toggle_selector.RS.active: > >> print ' RectangleSelector deactivated.' > >> toggle_selector.RS.set_active(False) > >> if event.key in ['A', 'a'] and not toggle_selector.RS.active: > >> print ' RectangleSelector activated.' > >> toggle_selector.RS.set_active(True) > >> > >> x = arange(100)/(99.0) > >> y = sin(x) > >> fig = figure > >> ax = subplot(111) > >> ax.plot(x,y) > >> > >> toggle_selector.RS = RectangleSelector(ax, onselect, drawtype='box') > >> connect('key_press_event', toggle_selector) > >> show() > >> > >> Gökhan > >> > >> > >> On Fri, Apr 17, 2009 at 2:31 AM, Matthias Michler > >> > >> <Mat...@gm...>wrote: > >>> Hi Gökhan, > >>> > >>> I recommend you to use matplotlib.widgets.RectangleSelector instead of > >>> the zoom functionality to select the data (An example can be found at > >>> > http://matplotlib.sourceforge.net/examples/widgets/rectangle_selector.htm > >>> l). This will return you the x and y-coordinate of button press and > button > >>> release > >>> event and with that you can take a portion of your data. > >>> Something like the following could be a starting point: > >>> x_min = min(eclick.xdata, erelease.xdata) > >>> x_max = max(eclick.xdata, erelease.xdata) > >>> x_new = x[(x>= x_min) & (x <= x_max)] > >>> > >>> where eclick and erelease correspond to the click and release event of > >>> the rectangle selection (see the example below). > >>> > >>> Opening a new figure after show can be achieved by: > >>> > >>> fig_new = plt.figure() > >>> # some plotting > >>> fig_new.show() # show up the new figure > >>> > >>> > >>> best regards Matthias > >>> > >>> > >>> yet another example for the usage of the RectangleSelector copied from > >>> its class documentation: > >>> > >>> """ > >>> Select a min/max range of the x axes for a matplotlib Axes > >>> > >>> Example usage:: > >>> > >>> from matplotlib.widgets import RectangleSelector > >>> from pylab import * > >>> > >>> def onselect(eclick, erelease): > >>> 'eclick and erelease are matplotlib events at press and > release' > >>> print ' startposition : (%f, %f)' % (eclick.xdata, > eclick.ydata) > >>> print ' endposition : (%f, %f)' % (erelease.xdata, > >>> erelease.ydata) > >>> print ' used button : ', eclick.button > >>> > >>> def toggle_selector(event): > >>> print ' Key pressed.' > >>> if event.key in ['Q', 'q'] and toggle_selector.RS.active: > >>> print ' RectangleSelector deactivated.' > >>> toggle_selector.RS.set_active(False) > >>> if event.key in ['A', 'a'] and not > toggle_selector.RS.active: > >>> print ' RectangleSelector activated.' > >>> toggle_selector.RS.set_active(True) > >>> > >>> x = arange(100)/(99.0) > >>> y = sin(x) > >>> fig = figure > >>> ax = subplot(111) > >>> ax.plot(x,y) > >>> > >>> toggle_selector.RS = RectangleSelector(ax, onselect, > >>> drawtype='line') > >>> connect('key_press_event', toggle_selector) > >>> show() > >>> """ > >>> > >>> On Friday 17 April 2009 02:26:51 Gökhan SEVER wrote: > >>>> Hello, > >>>> > >>>> A quick question: > >>>> > >>>> I am using two numpy arrays to plot the figure shown in attachment. Is > >>>> it possible to get array indices of selected X-axes while using the > >>>> zoom function? Later I can create a new figure from this selected > >>>> portion instead of the same figure and/or apply an analysis. > >>>> > >>>> Thank you. > >>> > ------------------------------------------------------------------------- > >>> ----- Stay on top of everything new and different, both inside and > >>> around Java (TM) technology - register by April 22, and save > >>> $200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco. > >>> 300 plus technical and hands-on sessions. Register today. > >>> Use priority code J9JMT32. http://p.sf.net/sfu/p > >>> _______________________________________________ > >>> Matplotlib-users mailing list > >>> Mat...@li... > >>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > > > > > > > > ------------------------------------------------------------------------------ > > Stay on top of everything new and different, both inside and > > around Java (TM) technology - register by April 22, and save > > $200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco. > > 300 plus technical and hands-on sessions. Register today. > > Use priority code J9JMT32. http://p.sf.net/sfu/p > > _______________________________________________ > > Matplotlib-users mailing list > > Mat...@li... > > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > > > > ------------------------------------------------------------------------------ > Stay on top of everything new and different, both inside and > around Java (TM) technology - register by April 22, and save > $200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco. > 300 plus technical and hands-on sessions. Register today. > Use priority code J9JMT32. http://p.sf.net/sfu/p > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > |
|
From: Gökhan S. <gok...@gm...> - 2009-04-20 21:16:45
|
Thanks for elegant trick Matthias.
I have modified onselect function following your suggestions, and it is
working as I wanted it to be. Select a portion and get a zoomed view in a
new figure.
def onselect(eclick, erelease):
# eclick and erelease are matplotlib events at press and release
global x_new
global y_new
print ' startposition : (%f, %f)' % (eclick.xdata, eclick.ydata)
print ' endposition : (%f, %f)' % (erelease.xdata, erelease.ydata)
print ' used button : ', eclick.button
xmin = min(eclick.xdata, erelease.xdata)
xmax = max(eclick.xdata, erelease.xdata)
ymin = min(eclick.ydata, erelease.ydata)
ymax = max(eclick.ydata, erelease.ydata)
indices = (x >= xmin) & (x <= xmax) & (y >= ymin) & (y <= ymax)
x_new = x[indices]
y_new = y[indices]
fig_new = figure()
plot(x_new, y_new)
fig_new.show()
There is still a minute point, that I would like mention again. Even though
I used global style variables I can't still see them when I quit the
program.
What I do is run the file within IPython by run command. In my case the file
is 'rect.py.' and I do run rect.py. When I quit and do whos querry, I can't
see global x_new nor y_new at the resulting lines:
In [13]: whos
Variable Type Data/Info
--------------------------------------------
RectangleSelector classobj matplotlib.widgets.RectangleSelector
ax AxesSubplot Axes(0.125,0.1;0.775x0.8)
fig function <function figure at 0xa752c6c>
onselect function <function onselect at 0xac0ec34>
toggle_selector function <function toggle_selector at 0xac0ef0c>
x ndarray 100: 100 elems, type `float64`, 800 bytes
y ndarray 100: 100 elems, type `float64`, 800 bytes
For the masking, I was planning to use a masking scheme as given below. Let
say I have an array which "a"
In [14]: a = arange(5)
In [15]: a
Out[15]: array([0, 1, 2, 3, 4])
and my secondary array is "b"
In [16]: b = array([2,3])
What I want to do is to mask a with b values and get an array of:
[array([False, False, True, True, False], dtype=bool)]
That is just an manually created array. I still don't know how to do this
programmatically in Pythonic fashion.
Again thanks for your help.
Gökhan
On Mon, Apr 20, 2009 at 4:09 AM, Matthias Michler
<Mat...@gm...>wrote:
> Hi Gökhan,
>
> On Friday 17 April 2009 20:21:00 Gökhan SEVER wrote:
> > Thanks for the pointer Matthias,
> >
> > That is exactly what I have been looking for.
> >
> > I use the code from the RectangleSelector class help with your suggested
> > code. I know that I have to update y-axis accordingly to x values such
> that
> > their positions and sizes must much so that I can plot them in a new
> plot.
> > And I know that the answer lies in a mask; I have to create a mask from
> > x_new and apply it to y. Do you have any hint on this?
>
> Unfortunately I'm not familiar with numpy masks, but what I would do is:
>
> xmin = min(eclick.xdata, erelease.xdata)
> xmax = max(eclick.xdata, erelease.xdata)
> ymin = min(eclick.ydata, erelease.ydata)
> ymax = max(eclick.ydata, erelease.ydata)
> # indices inside x-range
> indices = (x>= xmin) & (x <= xmax)
> # OR: indices for data inside the selected rectangle
> #indices = (x>= xmin) & (x <= xmax) & (y>=ymin) & (y<=ymax)
> xnew = x[indices]
> ynew = y[indices]
>
> > Another point is do you have any idea how to save values from inside
> > onselect action?
>
> What do you mean by saving?
> Saving to disk?
> # for ascii format I use:
> from scipy.io import write_array
>
> # for numpy arrays you can use
> import numpy as np
> a = np.arange(10)
> a.tofile # Write array to a file as text or binary.
>
> and I think there is also some Matplotlib function for this. In the module
> matplotlib.mlab, which also allows reading different types of formatted
> data.
>
> If you think of saving inside the program. You need a global variable
> (statement "global x" at the beginning of onselect) otherwise all variables
> are deleted at the end of each onselect call.
>
> > For some reason my ipython session doesn't remember values after I run
> the
> > given script:
>
> see three lines above, please.
>
> best regards Matthias
> >
> > from matplotlib.widgets import RectangleSelector
> > from pylab import *
> >
> > def onselect(eclick, erelease):
> > # eclick and erelease are matplotlib events at press and release
> > print ' startposition : (%f, %f)' % (eclick.xdata, eclick.ydata)
> > print ' endposition : (%f, %f)' % (erelease.xdata, erelease.ydata)
> > print ' used button : ', eclick.button
> > xmin = min(eclick.xdata, erelease.xdata)
> > xmax = max(eclick.xdata, erelease.xdata)
> > ymin = min(eclick.ydata, erelease.ydata)
> > ymax = max(eclick.ydata, erelease.ydata)
> > x_new = x[(x>= xmin) & (x <= xmax)]
> > #mask = [x == x_new[i] for i in range(len(x_new))]
> > #print mask
> > #print len(x_new)
> > #print len(y_new)
> > #fig_new = figure()
> > #plot(x_new, y_new)
> > #fig_new.show()
> >
> > def toggle_selector(event):
> > print ' Key pressed.'
> > if event.key in ['Q', 'q'] and toggle_selector.RS.active:
> > print ' RectangleSelector deactivated.'
> > toggle_selector.RS.set_active(False)
> > if event.key in ['A', 'a'] and not toggle_selector.RS.active:
> > print ' RectangleSelector activated.'
> > toggle_selector.RS.set_active(True)
> >
> > x = arange(100)/(99.0)
> > y = sin(x)
> > fig = figure
> > ax = subplot(111)
> > ax.plot(x,y)
> >
> > toggle_selector.RS = RectangleSelector(ax, onselect, drawtype='box')
> > connect('key_press_event', toggle_selector)
> > show()
> >
> > Gökhan
> >
> >
> > On Fri, Apr 17, 2009 at 2:31 AM, Matthias Michler
> >
> > <Mat...@gm...>wrote:
> > > Hi Gökhan,
> > >
> > > I recommend you to use matplotlib.widgets.RectangleSelector instead of
> > > the zoom functionality to select the data (An example can be found at
> > >
> http://matplotlib.sourceforge.net/examples/widgets/rectangle_selector.htm
> > >l). This will return you the x and y-coordinate of button press and
> button
> > > release
> > > event and with that you can take a portion of your data.
> > > Something like the following could be a starting point:
> > > x_min = min(eclick.xdata, erelease.xdata)
> > > x_max = max(eclick.xdata, erelease.xdata)
> > > x_new = x[(x>= x_min) & (x <= x_max)]
> > >
> > > where eclick and erelease correspond to the click and release event of
> > > the rectangle selection (see the example below).
> > >
> > > Opening a new figure after show can be achieved by:
> > >
> > > fig_new = plt.figure()
> > > # some plotting
> > > fig_new.show() # show up the new figure
> > >
> > >
> > > best regards Matthias
> > >
> > >
> > > yet another example for the usage of the RectangleSelector copied from
> > > its class documentation:
> > >
> > > """
> > > Select a min/max range of the x axes for a matplotlib Axes
> > >
> > > Example usage::
> > >
> > > from matplotlib.widgets import RectangleSelector
> > > from pylab import *
> > >
> > > def onselect(eclick, erelease):
> > > 'eclick and erelease are matplotlib events at press and
> release'
> > > print ' startposition : (%f, %f)' % (eclick.xdata,
> eclick.ydata)
> > > print ' endposition : (%f, %f)' % (erelease.xdata,
> > > erelease.ydata)
> > > print ' used button : ', eclick.button
> > >
> > > def toggle_selector(event):
> > > print ' Key pressed.'
> > > if event.key in ['Q', 'q'] and toggle_selector.RS.active:
> > > print ' RectangleSelector deactivated.'
> > > toggle_selector.RS.set_active(False)
> > > if event.key in ['A', 'a'] and not
> toggle_selector.RS.active:
> > > print ' RectangleSelector activated.'
> > > toggle_selector.RS.set_active(True)
> > >
> > > x = arange(100)/(99.0)
> > > y = sin(x)
> > > fig = figure
> > > ax = subplot(111)
> > > ax.plot(x,y)
> > >
> > > toggle_selector.RS = RectangleSelector(ax, onselect,
> > > drawtype='line')
> > > connect('key_press_event', toggle_selector)
> > > show()
> > > """
> > >
> > > On Friday 17 April 2009 02:26:51 Gökhan SEVER wrote:
> > > > Hello,
> > > >
> > > > A quick question:
> > > >
> > > > I am using two numpy arrays to plot the figure shown in attachment.
> Is
> > > > it possible to get array indices of selected X-axes while using the
> > > > zoom function? Later I can create a new figure from this selected
> > > > portion instead of the same figure and/or apply an analysis.
> > > >
> > > > Thank you.
> > >
> > >
> -------------------------------------------------------------------------
> > >----- Stay on top of everything new and different, both inside and
> > > around Java (TM) technology - register by April 22, and save
> > > $200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco.
> > > 300 plus technical and hands-on sessions. Register today.
> > > Use priority code J9JMT32. http://p.sf.net/sfu/p
> > > _______________________________________________
> > > Matplotlib-users mailing list
> > > Mat...@li...
> > > https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
>
>
> ------------------------------------------------------------------------------
> Stay on top of everything new and different, both inside and
> around Java (TM) technology - register by April 22, and save
> $200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco.
> 300 plus technical and hands-on sessions. Register today.
> Use priority code J9JMT32. http://p.sf.net/sfu/p
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
|
|
From: fjldurodie <fre...@go...> - 2009-04-20 21:09:21
|
Hi, I'm wondering if it is possible to use SpanSelector on multiple figures : my problem is that I can't think of a way to tell the onselect on which axes(ses) of which figure it should try and do something. The example works because there is only one SpanSelector active and "it" therefore knows which axes "it" should redraw. For it to work on multiple figures (say I have a series of events that I plot in a similar way each in a separate figure and I would like a SpanSelector feature on each of the figures) I would need to have a reference to which axes called the onselect through SpanSelector : then I could get the axes's figure and manipulate the other subplots on that figure accordingly. Is there a way of doing this ? Kind regards, Frederic |