Re: [Matplotlib-users] Feature Request: RectangleSelector BlockingInput

2008-08-14 Thread David M. Kaplan
Hi,

Sorry for the long delay - I have been on vacation.  I don't use the
imcrop function, but it looks fairly easy to implement using ginput.  I
am heading off for vacation again for another two weeks and I want to
get in some of the changes I proposed a long while ago before working on
this, so it might be a while, but if no one can take it on first, I can
give a look next month.

Cheers,
David



On Tue, 2008-08-05 at 19:51 -0500, John Hunter wrote:
 On Tue, Aug 5, 2008 at 6:26 PM, Elfnor [EMAIL PROTECTED] wrote:
 
  This would be really useful for implementing a user image crop function,
  similar to matlab's imcrop for example.
 
 David, since you are a recent matlab user and are deeply versed in the
 blocking code: how hard would it be to simply provide a (mostly)
 matlab compatible imcrop function, and is this something you are
 interested in doing?
 
 JDH
-- 
**
David M. Kaplan
Charge de Recherche 1
Institut de Recherche pour le Developpement
Centre de Recherche Halieutique Mediterraneenne et Tropicale
av. Jean Monnet
B.P. 171
34203 Sete cedex
France

Phone: +33 (0)4 99 57 32 27
Fax: +33 (0)4 99 57 32 95
http://www.ur097.ird.fr/team/dkaplan/index.html
**



-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK  win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100url=/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Control space between bars

2008-08-14 Thread Jae-Joon Lee
Hi Mathieu,

It seems to me that you're confused with the meaning of the transAxes.
It is a transform from the Axes coordinate to the Canvas(?) coordinate.
As far as I can see, what you seemed to want is a transform between
Data coordinate and Axes coordinate, and that would be transScale +
transLimits (from Data to Axes).

So, try

   trans = (ax.transScale + ax.transLimits).inverted()
   # trans = ax.transLimits.inverted() will also work in this case.

and you will get 2.0, 2.0 as you expected.

The transform argument should be transAxes still.

   ax.text(valx, valy, actualcoords, transform=ax.transAxes)

As far as your original question is concerned, I have little idea what
you are trying to do, so I'll leave that question to others.

Regards,

-JJ


On Thu, Aug 14, 2008 at 3:43 PM, Mathieu Leplatre [EMAIL PROTECTED] wrote:
 I am still investigating and I am stuck at converting transAxes values to 
 data.

 If my axes goes from 10.0 to 20.0 then transAxes 0.5 should give me 15.0.

 This would allow me to compute bar width and space, since I am able to
 convert inches to transAxes values.

 I tried many combinations of transAxes, transData, ...,
 inverse_xy_tup, xy_tup, inverted(), transform(), ... without success
 :(

 Any ideas please ?

 -
 import pylab as P
 import matplotlib.transforms as T

 x = P.arange(5)
 y = P.rand(5) * 4
 ax = P.subplot(1,1,1)
 P.plot(x,y)
 ax.set_ylim(0.0, 4.0)

 trans = ax.transAxes
 valx = valy = 0.5
 actualcoords = %s % trans.transform([valx, valy])
 #Gives me [328, 240] instead of [2.0, 2.0]

 ax.text(valx, valy, actualcoords, transform=trans)
 P.show()

 -



 On Wed, Aug 13, 2008 at 10:34 AM, Mathieu Leplatre [EMAIL PROTECTED] wrote:
 Hi all,

 I've searched in examples and archives and could not find anything
 about manual control of space between bars.

 By default, the bars in the following script overlap.

 So I guess the behaviour is :
 specify chart width (8in) + bar width (0.8) = auto bar space

 And I would like to know how to do :
 specify chart width + bar space = auto bar width
 specify bar space + bar width = auto chart width (fixed margins)

 But I can't figure it out, especially the latter. Can
 matplotlib.transforms help me about the former ?

 Do you have documentation reference or some hints about that please ?
 Thanks!

 I am plotting a chronological bar chart like this one :

 #!/usr/bin/env python
 import matplotlib, pylab, numpy
 import datetime

 def rangedates( hourstep ):
dates = []
for d in range(1,31):
for h in range(0,24,hourstep):
dt = datetime.datetime(2008,06,d,h)
dates.append(dt)
return pylab.date2num(dates)

 # Plot value every 12H
 abscissa = rangedates(12)

 barstep  = abscissa[1] - abscissa[0]
 barspace = 0.5 * barstep
 barwidth = barstep - barspace

 fig = pylab.figure()
 ax  = fig.add_subplot(111)
 fmt = matplotlib.dates.DateFormatter('%b %d')
 ax.xaxis.set_major_formatter( fmt )
 fig.autofmt_xdate()

 pylab.bar( abscissa, numpy.random.randn( len(abscissa) ),
   width = barwidth)
 pylab.show()


 -
 This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
 Build the coolest Linux based applications with Moblin SDK  win great prizes
 Grand prize is a trip for two to an Open Source event anywhere in the world
 http://moblin-contest.org/redirect.php?banner_id=100url=/
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users


-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK  win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100url=/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Arrow Questions

2008-08-14 Thread Ben Axelrod
I am trying to implement a dynamic graph in mpl, where users can drag around 
the nodes, and the edges follow the nodes like rubber bands.  I have this 
working with regular edges, but I want to give the option of putting arrows on 
the edges.  I am running into some issues with the Arrow classes.

With my Text, Rectangle, and Line2D objects I can get and set their locations 
with methods such as get_position(), get_x(), and get_xdata() respectively.  
But there are no such methods for any of the Arrow classes.   (By the way, it 
seems like these sorts of things would be in the base classes, and much more 
standard).

What is the difference between Arrow, YAArrow, and FancyArrow anyway?  (Besides 
drastically different scales).

Some other features of the Arrow class that I would like very much are:
* double headed arrows (one line with an arrow head on each end)
 * the ability to turn the arrow head on and off easily (Boolean parameter 
function)

Does anyone have any ideas on how to work around these issues?
Thanks,
-Ben

-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK  win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100url=/___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Scaling axes not data?

2008-08-14 Thread Boris Barbour
Eric and John,

Thanks for the information. You are right that this probably would have been a 
premature optimisation, even if it weren't rendered useless by matplotlib 
using doubles internally (which I hadn't realised). The thought just occurred 
to me as I was writing the data-scaling part of my script.

The script is intended to be somewhat interactive. Initial tests suggest that 
plotting or updating several subplots from memory does take a quite 
noticeable time (e.g. 1.2 -- 1.5 seconds for 3 subplots of 1 points) that 
will probably become annoying in routine use. As you indicated, basically all 
that time is spent within matplotlib. I'm just using standard default calls:

for i in subplot
subplot 
plot
xlabel
ylabel
title

Each of these calls seems to take roughly the same time (60--100ms). If 
anybody has pointers on speeding things up significantly, I'm all ears. 
(Predefining data limits? Using lower-level commands? Use of a non-default 
backend?)

Boris


-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK  win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100url=/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Scaling axes not data?

2008-08-14 Thread Eric Firing

Boris Barbour wrote:

Eric and John,

Thanks for the information. You are right that this probably would have been a 
premature optimisation, even if it weren't rendered useless by matplotlib 
using doubles internally (which I hadn't realised). The thought just occurred 
to me as I was writing the data-scaling part of my script.


The script is intended to be somewhat interactive. Initial tests suggest that 
plotting or updating several subplots from memory does take a quite 
noticeable time (e.g. 1.2 -- 1.5 seconds for 3 subplots of 1 points) that 
will probably become annoying in routine use. As you indicated, basically all 
that time is spent within matplotlib. I'm just using standard default calls:


for i in subplot
subplot 
plot
xlabel
ylabel
title

Each of these calls seems to take roughly the same time (60--100ms). If 


It sounds like you have interactive mode on, in which case each pylab 
function redraws the figure.  The solution is to use the object-oriented 
interface for almost everything.  See the attached example.


anybody has pointers on speeding things up significantly, I'm all ears. 
(Predefining data limits? Using lower-level commands? Use of a non-default 
backend?)


If the suggestion above is not enough, we will need to know more about 
what your script looks like, the environment in which it is running 
(e.g., ipython? embedded in wx? straight command line? what operating 
system? what backend?), your constraints, and what you are trying to 
accomplish.  The best thing would be if you could post a very short 
self-contained script, typically using fake random data, that shows your 
present approach and that illustrates the speed problem; then we can try 
to figure out what the bottlenecks are, and whether there are simple 
ways to speed up the script or to modify mpl for better speed.


Eric

import time
import numpy as np
import matplotlib.pyplot as plt

npts = 1
xx = np.arange(npts)

plt.ion()

t0 = time.time()
fig1 = plt.figure()
ax = fig1.add_subplot(1,1,1)
# Try again, commenting out the following three lines;
# you will see no significant difference in the plotting time.
ax.set_title('A title')
ax.set_xlabel('This is X')
ax.set_ylabel('This is Y')

lines = ax.plot(xx, np.random.rand(npts))
plt.draw()
t1 = time.time()

print t1-t0

for ii in range(10):
t0 = time.time()
lines[0].set_data(xx, np.random.rand(npts))
plt.draw()
t1 = time.time()

print t1-t0


-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK  win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100url=/___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users