Re: [Matplotlib-users] Colorbar embedding in qt4

2010-01-03 Thread Laurent Dufrechou
Hello,

You are using the TK backend.
Add this at the top of your script:

import matplotlib
matplotlib.use('QT4Agg')

from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as
FigureCanvas
from matplotlib.backends.backend_qt4agg import NavigationToolbar2QTAgg as
NavigationToolbar

Should work.
(Or at least will no more show errors related to TK backend...)

Laurent
--
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev ___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Bliting speed improvment patch (QT4Agg backend) + example of sliding demo

2009-11-30 Thread Laurent Dufrechou
Hi there,

Finally with lot of try I've finally managed to make blitting of a cmap
working.
I've also patched QT4agg backend, to make a redraw immediately.
(replaced self.draw by self.repaint)
In my current project I was able to stream a 655KB network stream, do
demodulation of an IQ stream and display the spectrogram in real time (4096
pixel per 1024) with matplotlib and QT4 backend, thx to the patch + blitting
example attached.

Without patch, the refrech was veeery long. (waiting for QT loop to execute
code wen it wanted.)
And do NOT always work. If you've got a powerfull pc you've got chance to
see only white background...
(or simply the loop timer to 0, you will see that without patch blit does
not work).

Only tested under windows currently, 'cause my project is on windows
currently...

There is one bug in the example, that I didn't manage to correct yet.
Depending on screen resolution, the color of the cmap blitted area can be
kind of alpha'ed. (that is look like a little bit transparent...) , Any idea
on the root of this issue?

By the way to make the example work I needed to do this:
self.ax2.draw_artist(self.line2)
self.blit(self.ax2.bbox)
self.restore_region(self.background2)

that is blit before restore... don't understand why yet.

Any comment welcomed.

Is there any chance, after review, to find a way to include this in main
trunk?
What do think about this?

Cheers,
Laurent

Render to qt from agg

from __future__ import division

import os, sys

import matplotlib
from matplotlib.figure import Figure

from backend_agg import FigureCanvasAgg
from backend_qt4 import QtCore, QtGui, FigureManagerQT, FigureCanvasQT,\
 show, draw_if_interactive, backend_version, \
 NavigationToolbar2QT

DEBUG = False


def new_figure_manager( num, *args, **kwargs ):

Create a new figure manager instance

if DEBUG: print 'backend_qtagg.new_figure_manager'
FigureClass = kwargs.pop('FigureClass', Figure)
thisFig = FigureClass( *args, **kwargs )
canvas = FigureCanvasQTAgg( thisFig )
return FigureManagerQT( canvas, num )

class NavigationToolbar2QTAgg(NavigationToolbar2QT):
def _get_canvas(self, fig):
return FigureCanvasQTAgg(fig)

class FigureManagerQTAgg(FigureManagerQT):
def _get_toolbar(self, canvas, parent):
# must be inited after the window, drawingArea and figure
# attrs are set
if matplotlib.rcParams['toolbar']=='classic':
print Classic toolbar is not supported
elif matplotlib.rcParams['toolbar']=='toolbar2':
toolbar = NavigationToolbar2QTAgg(canvas, parent)
else:
toolbar = None
return toolbar

class FigureCanvasQTAgg( FigureCanvasQT, FigureCanvasAgg ):

The canvas the figure renders into.  Calls the draw and print fig
methods, creates the renderers, etc...

Public attribute

  figure - A Figure instance
   

def __init__( self, figure ):
if DEBUG: print 'FigureCanvasQtAgg: ', figure
FigureCanvasQT.__init__( self, figure )
FigureCanvasAgg.__init__( self, figure )
self.drawRect = False
self.rect = []
self.replot = True
self.setAttribute(QtCore.Qt.WA_OpaquePaintEvent)

def drawRectangle( self, rect ):
self.rect = rect
self.drawRect = True
self.repaint( )

def paintEvent( self, e ):

Draw to the Agg backend and then copy the image to the qt.drawable.
In Qt, all drawing should be done inside of here when a widget is
shown onscreen.


#FigureCanvasQT.paintEvent( self, e )
if DEBUG: print 'FigureCanvasQtAgg.paintEvent: ', self, \
   self.get_width_height()

# only replot data when needed
if type(self.replot) is bool: # might be a bbox for blitting
if self.replot:
FigureCanvasAgg.draw(self)

# matplotlib is in rgba byte order.  QImage wants to put the bytes
# into argb format and is in a 4 byte unsigned int.  Little endian
# system is LSB first and expects the bytes in reverse order
# (bgra).
if QtCore.QSysInfo.ByteOrder == QtCore.QSysInfo.LittleEndian:
stringBuffer = self.renderer._renderer.tostring_bgra()
else:
stringBuffer = self.renderer._renderer.tostring_argb()

qImage = QtGui.QImage(stringBuffer, self.renderer.width,
  self.renderer.height,
  QtGui.QImage.Format_ARGB32)
p = QtGui.QPainter(self)
p.drawPixmap(QtCore.QPoint(0, 0), QtGui.QPixmap.fromImage(qImage))

# draw the zoom rectangle to the QPainter
if self.drawRect:
p.setPen( QtGui.QPen( QtCore.Qt.black, 1, QtCore.Qt.DotLine ) )
p.drawRect( self.rect[0], self.rect[1], self.rect[2], 
self.rect[3] )

p.end()

Re: [Matplotlib-users] set figure position

2009-11-22 Thread Laurent Dufrechou
Hi marie,

You can define exactly the size and position of your plot like this:

fig = Figure()
axe = fig.add_axes([pos_x,pos_y,size_x,size_y])
axe.plot(x, y, 'b')

where pos_x,pos_y is a number (0n1) and 0,0 is bottom left
size_x, size_x is a number (0n1)
1 is full figure size.

Ex: axe = fig.add_axes([0.1,0.1,0.8,0.2])

Plot @10% x,10% y from bottom left
And size is 80% of figure x size and 20% of figure y size.


Laurent

-Message d'origine-
De : Marie De La Fontaine [mailto:marie.delafonta...@yahoo.com] 
Envoyé : dimanche 22 novembre 2009 18:05
À : matplotlib-users@lists.sourceforge.net
Objet : [Matplotlib-users] set figure position

We have recently switched to matplotlib after having done all plotting with
pure wxPython for years.

There is one problem we cannot solve. With wxPython we are free to set the
geometry (position and size) of each Frame anywhere on the screen. We have
developed a heuristic solution which packs the Frames automatically
according to a pattern that can be recognized after a user has manually
repositioned a few Frames on the screen. For example, some users tend to
align their figures in a row, others subdivide the available space for
different groups of figures, and so on. Please let us know if anyone is
interested to integrate this heuristic packing into matplotlib.

The important question is:
How can we set the position of a Figure on the screen using matplotlib?
There is a function Figure.set_size_inches, but no function to move the
Figure to a new position. Please help.

Regards,
Marie


__
Do You Yahoo!?
Sie sind Spam leid? Yahoo! Mail verfügt über einen herausragenden Schutz
gegen Massenmails. 
http://mail.yahoo.com 



--
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus
on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


--
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Little issue with blitting technique

2009-10-16 Thread Laurent Dufrechou
Bug reported:

https://sourceforge.net/tracker/index.php?func=detailaid=2880692group_id=80706atid=560720

Does anybody where I could dig a little to try to correct it?
It a really needed feature for me, so if I could help...

Cheers,
Laurent

 -Message d'origine-
 De : Jae-Joon Lee [mailto:lee.j.j...@gmail.com]
 Envoyé : jeudi 15 octobre 2009 05:23
 À : Laurent Dufrechou
 Cc : matplotlib-users@lists.sourceforge.net
 Objet : Re: [Matplotlib-users] Little issue with blitting technique
 
 On Tue, Oct 13, 2009 at 1:02 PM, Laurent Dufrechou
 ldufrec...@marport.com wrote:
  Hello,
 
  I've tested so far with wx and QT4 backend.
  The two are buggy.
  Easy way to reproduce the bug (another way I mean)
 
  ax = p.subplot(212)
  ax2 = p.subplot(211)
 
 
 On mac with wxgtk, it works fine.
 Maybe this is an windows only issue.
 
  and the two backends got the same error.
 
 Since nobody steped in, and I don't use windows, can you file a bug
 report.
 
 http://sourceforge.net/tracker/?atid=560720group_id=80706func=browse
 
 Please provide a short, complete example that reproduces the bug. Also
 the error message you get.
 
 -JJ
 
 
 
  Note that I'm under windows. I'll try under linux tonight just to
 check.
  I'll also try gtk backend as you suggest.
 
  Update in next email :)
 
  -Message d'origine-
  De : Jae-Joon Lee [mailto:lee.j.j...@gmail.com]
  Envoyé : mardi 13 octobre 2009 18:36
  À : Laurent Dufrechou
  Cc : matplotlib-users@lists.sourceforge.net
  Objet : Re: [Matplotlib-users] Little issue with blitting technique
 
  I haven't tested it with qt4, but with gtk, add_axes DOES work.
 
  So, can you try other backends and see if they work?
 
  And, I believe that add_subplot - add_axes is a only change you
 made?
 
  Unless the problem is persistent among other backends, I hope other
  developers who use qt4 backend step in and help.
 
  Regards,
 
  -JJ
 
 
  On Thu, Oct 8, 2009 at 11:30 AM, Laurent Dufrechou
  ldufrec...@marport.com wrote:
   Hello,
  
  
  
   I’ve just discovered blitting technique to improve performances.
  
   I’m using this example
  
 
 http://matplotlib.sourceforge.net/examples/animation/animation_blit_qt4
  .html
  
  
  
   I encounter an issue if instead of using subplot I use add_axes
  method to
   hand define where I want my plot.
  
   In this case blitting is no more working like if restore_region
 was
  not
   restoring context…
  
  
  
   def __init__(self):
  
       FigureCanvas.__init__(self, Figure())
  
  
  
       #self.ax = self.figure.add_subplot(111)
  
       self.ax = self.figure.add_axes([0.1,0.1,0.8,0.2])
  
  
  
   Any idea why in this case the example given is not working?
  
  
  
   Cheers,
  
   Laurent
  
   --
 ---
  -
   Come build with us! The BlackBerry(R) Developer Conference in SF,
 CA
   is the only developer event you need to attend this year.
 Jumpstart
  your
   developing skills, take BlackBerry mobile applications to market
 and
  stay
   ahead of the curve. Join us from November 9 - 12, 2009. Register
 now!
   http://p.sf.net/sfu/devconference
   ___
   Matplotlib-users mailing list
   Matplotlib-users@lists.sourceforge.net
   https://lists.sourceforge.net/lists/listinfo/matplotlib-users
  
  
 
--
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] TR: Cleaver way to do a scrolling imshow?

2009-10-16 Thread Laurent Dufrechou
Hello,

I'm investigating a way to make a sort of imshow that is scrolling from
right to left.

My idea is to copy in a blit buffer from (1,0) to (xmax,ymax).

Blit it @(0,0) (xmax-1,ymax)

And then draw a cmap'ed line @x=xmax.

 

So here are my question:

 

How to draw a line that use a cmap=jet (for example)?

I've taken a look at Line2D but it has no cmap argument. The only thing I've
found is drawing a line with only one color.

 

Any idea appreciated!

 

Cheers,

Laurent

--
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Cleaver way to do a scrolling imshow?

2009-10-16 Thread Laurent Dufrechou
Hello,

I'm investigating a way to make a sort of imshow that is scrolling from
right to left.

My idea is to copy in a blit buffer from (1,0) to (xmax,ymax).

Blit it @(0,0) (xmax-1,ymax)

And then draw a cmap'ed line @x=xmax.

 

So here are my question:

 

How to draw a line that use a cmap=jet (for example)?

I've taken a look at Line2D but it has no cmap argument. The only thing
I've found is drawing a line with only one color...

 

Any idea appreciated!

 

Cheers,

Laurent

 

 

--
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Little issue with blitting technique

2009-10-13 Thread Laurent Dufrechou
Hello,

I've tested so far with wx and QT4 backend.
The two are buggy.
Easy way to reproduce the bug (another way I mean)

ax = p.subplot(212)
ax2 = p.subplot(211)

and the two backends got the same error.

Note that I'm under windows. I'll try under linux tonight just to check.
I'll also try gtk backend as you suggest.

Update in next email :)

 -Message d'origine-
 De : Jae-Joon Lee [mailto:lee.j.j...@gmail.com]
 Envoyé : mardi 13 octobre 2009 18:36
 À : Laurent Dufrechou
 Cc : matplotlib-users@lists.sourceforge.net
 Objet : Re: [Matplotlib-users] Little issue with blitting technique
 
 I haven't tested it with qt4, but with gtk, add_axes DOES work.
 
 So, can you try other backends and see if they work?
 
 And, I believe that add_subplot - add_axes is a only change you made?
 
 Unless the problem is persistent among other backends, I hope other
 developers who use qt4 backend step in and help.
 
 Regards,
 
 -JJ
 
 
 On Thu, Oct 8, 2009 at 11:30 AM, Laurent Dufrechou
 ldufrec...@marport.com wrote:
  Hello,
 
 
 
  I’ve just discovered blitting technique to improve performances.
 
  I’m using this example
 
 http://matplotlib.sourceforge.net/examples/animation/animation_blit_qt4
 .html
 
 
 
  I encounter an issue if instead of using subplot I use add_axes
 method to
  hand define where I want my plot.
 
  In this case blitting is no more working like if restore_region was
 not
  restoring context…
 
 
 
  def __init__(self):
 
      FigureCanvas.__init__(self, Figure())
 
 
 
      #self.ax = self.figure.add_subplot(111)
 
      self.ax = self.figure.add_axes([0.1,0.1,0.8,0.2])
 
 
 
  Any idea why in this case the example given is not working?
 
 
 
  Cheers,
 
  Laurent
 
  -
 -
  Come build with us! The BlackBerry(R) Developer Conference in SF, CA
  is the only developer event you need to attend this year. Jumpstart
 your
  developing skills, take BlackBerry mobile applications to market and
 stay
  ahead of the curve. Join us from November 9 - 12, 2009. Register now!
  http://p.sf.net/sfu/devconference
  ___
  Matplotlib-users mailing list
  Matplotlib-users@lists.sourceforge.net
  https://lists.sourceforge.net/lists/listinfo/matplotlib-users
 
 
--
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Little issue with blitting technique

2009-10-12 Thread Laurent Dufrechou
Hello,

 

I've just discovered blitting technique to improve performances.

I'm using this example
http://matplotlib.sourceforge.net/examples/animation/animation_blit_qt4.
html

 

I encounter an issue if instead of using subplot I use add_axes method
to hand define where I want my plot.

In this case blitting is no more working like if restore_region was not
restoring context...

 

def __init__(self):

FigureCanvas.__init__(self, Figure())

 

#self.ax = self.figure.add_subplot(111)

self.ax = self.figure.add_axes([0.1,0.1,0.8,0.2])

 

Any idea why in this case the example given is not working?

 

Cheers,

Laurent

--
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Some icons do not showup after packaging with py2exe or pyinstaller

2009-10-12 Thread Laurent Dufrechou
Hello,

 

Whether method I use to package my python app, I always reach the issue
where the toolbar does not display some icons whiel the subplot is
well displayed.

Each time the packaging method copy mpl-data where the .exe is created
so file are or should be at the right location.

Does anybody has encountered this issue /solved it?

 

If not, can someone explain me the basic process behind finding the
pictures inside matplotlib? So I'l try to debug this with py2exe and
pyinstaller team.

Ps: using matplotlib 0.99.1 + pyqt 4.4

 

Thx a lot for any direction!

 

Laurent

attachment: packaging_issue.png--
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Some icons do not showup after packaging with py2exe or pyinstaller

2009-10-09 Thread Laurent Dufrechou
Hello,

 

Whether method I use to package my python app, I always reach the issue
where the toolbar does not display some icons whiel the subplot is well
displayed.

Each time the packaging method copy mpl-data where the .exe is created so
file are or should be at the right location.

Does anybody has encountered this issue /solved it?

 

If not, can someone explain me the basic process behind finding the pictures
inside matplotlib? So I'l try to debug this with py2exe and pyinstaller
team.

Ps: using matplotlib 0.99.1 + pyqt 4.4

 

Thx a lot for any direction!

 

Laurent

attachment: packaging_issue.png--
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Testing email becuase my previuous didn't want to appear...

2009-10-08 Thread Laurent Dufrechou
.

Laurent

--
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Little issue with blitting technique

2009-10-08 Thread Laurent Dufrechou
Hello,

 

I've just discovered blitting technique to improve performances.

I'm using this example
http://matplotlib.sourceforge.net/examples/animation/animation_blit_qt4.html

 

I encounter an issue if instead of using subplot I use add_axes method to
hand define where I want my plot.

In this case blitting is no more working like if restore_region was not
restoring context.

 

def __init__(self):

FigureCanvas.__init__(self, Figure())

 

#self.ax = self.figure.add_subplot(111)

self.ax = self.figure.add_axes([0.1,0.1,0.8,0.2])

 

Any idea why in this case the example given is not working?

 

Cheers,

Laurent

--
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Little issue with blitting technique [Update]

2009-10-08 Thread Laurent Dufrechou
Hello,

Continuing on my previous email, I'm using this example:

http://matplotlib.sourceforge.net/examples/animation/animation_blit_qt4.html

 

def __init__(self):

FigureCanvas.__init__(self, Figure())

 

self.ax = self.figure.add_subplot(111)

self.ax.set_position([0.1,0.05,0.5,0.9]) 

 

works, but:

 

def __init__(self):

FigureCanvas.__init__(self, Figure())

 

self.ax = self.figure.add_subplot(111)

self.ax.set_position([0.1,0.1,0.5,0.9])



is not working L, the region is wrongly blitted and some part of the graph
is not restored.

 

I think there is a bug in the refresh of the bounding box or something like
this.

 

Using matplotlib 0.99.1.1 python2.5 win32 pyqt4 4.4.3.7 (given with
python(x,y) 2.1.17)

 

Laurent

--
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Little help needed with pqt ...

2009-09-11 Thread Laurent Dufrechou
Hello,

I face a very boring problem.
Here is a little modified pyqt widget example found on matplotlib website.
Basicaly I've just added a tab widget and inside it a matplotlib widget.

Sadly, on creation the widget don't get the full size of the PA_tab widget
:(
BUT once I resize manually the app all became OK...

To be honest I've got NO idea of what is the problem :(

Any direction highly appreciated!

Laurent

matplotlib:
__version__  = '0.98.5.2'

And pyqt: 4.4.3.6


#!/usr/bin/env python

# embedding_in_qt4.py --- Simple Qt4 application embedding matplotlib canvases
#
# Copyright (C) 2005 Florent Rougon
#   2006 Darren Dale
#
# This file is an example program for matplotlib. It may be used and
# modified with no restriction; raw copies as well as modified versions
# may be distributed without limitation.

import sys, os, random
from PyQt4 import QtGui, QtCore

from numpy import arange, sin, pi
from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas
from matplotlib.figure import Figure

progname = os.path.basename(sys.argv[0])
progversion = 0.1


class MyMplCanvas(FigureCanvas):
Ultimately, this is a QWidget (as well as a FigureCanvasAgg, etc.).
def __init__(self, parent=None, width=5, height=4, dpi=100):
fig = Figure(figsize=(width, height), dpi=dpi)
self.axes = fig.add_subplot(111)
# We want the axes cleared every time plot() is called
self.axes.hold(False)

self.compute_initial_figure()

#
FigureCanvas.__init__(self, fig)
self.setParent(parent)

FigureCanvas.setSizePolicy(self,
   QtGui.QSizePolicy.Expanding,
   QtGui.QSizePolicy.Expanding)
FigureCanvas.updateGeometry(self)


def compute_initial_figure(self):
pass


class MyStaticMplCanvas(MyMplCanvas):
Simple canvas with a sine plot.
def compute_initial_figure(self):
t = arange(0.0, 3.0, 0.01)
s = sin(2*pi*t)
self.axes.plot(t, s)


class MyDynamicMplCanvas(MyMplCanvas):
A canvas that updates itself every second with a new plot.
def __init__(self, *args, **kwargs):
MyMplCanvas.__init__(self, *args, **kwargs)
timer = QtCore.QTimer(self)
QtCore.QObject.connect(timer, QtCore.SIGNAL(timeout()), 
self.update_figure)
timer.start(1000)

def compute_initial_figure(self):
 self.axes.plot([0, 1, 2, 3], [1, 2, 0, 4], 'r')

def update_figure(self):
# Build a list of 4 random integers between 0 and 10 (both inclusive)
l = [ random.randint(0, 10) for i in xrange(4) ]

self.axes.plot([0, 1, 2, 3], l, 'r')
self.draw()


class ApplicationWindow(QtGui.QMainWindow):
def __init__(self):
QtGui.QMainWindow.__init__(self)
self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
self.setWindowTitle(application main window)

self.centralwidget  = QtGui.QWidget(self)
self.verticalLayout = QtGui.QVBoxLayout(self.centralwidget)
self.MainTab = QtGui.QTabWidget(self.centralwidget)
self.verticalLayout.addWidget(self.MainTab)
self.PA_tab  = QtGui.QWidget()
self.MainTab.addTab(self.PA_tab, )
toto = MyDynamicMplCanvas(self.PA_tab)

self.vLayout = QtGui.QVBoxLayout(self.PA_tab)
self.vLayout.addWidget(toto)


self.setCentralWidget(self.centralwidget)
self.resize(QtCore.QSize(1024,900))

def fileQuit(self):
self.close()

def closeEvent(self, ce):
self.fileQuit()

def about(self):
QtGui.QMessageBox.about(self, About %s % progname,
u%(prog)s version %(version)s
Copyright \N{COPYRIGHT SIGN} 2005 Florent Rougon, 2006 Darren Dale

This program is a simple example of a Qt4 application embedding matplotlib
canvases.

It may be used and modified with no restriction; raw copies as well as
modified versions may be distributed without limitation.
% {prog: progname, version: progversion})


qApp = QtGui.QApplication(sys.argv)

aw = ApplicationWindow()
aw.setWindowTitle(%s % progname)
aw.show()
sys.exit(qApp.exec_())
#qApp.exec_()
--
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Re :Re: Little help need ed with pqt ...

2009-09-11 Thread laurent . dufrechou

Hi Darren,

Thanks for your answer.
... I've updated to matplotlib 0.99 since the last email... and the bug  
disappeared :)
Must be a bug of previous version since I had ever added a layout to the  
central widget!


Thanks anyway for your help!


On Fri, Sep 11, 2009 at 5:52 PM, Laurent Dufrechou



laurent.dufrec...@gmail.com wrote:



 Hello,







 I face a very boring problem.


 Here is a little modified pyqt widget example found on matplotlib  
website.



 Basicaly I've just added a tab widget and inside it a matplotlib widget.






 Sadly, on creation the widget don't get the full size of the PA_tab  
widget



 :(



 BUT once I resize manually the app all became OK...







 To be honest I've got NO idea of what is the problem :(







 Any direction highly appreciated!





Try adding a layout to the central widget and adding your tab widget



to that layout.





Darren


--
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] [PyQt] Pydee v0.3.0

2009-03-11 Thread Laurent Dufrechou
Hey pierre,
Wow that's fantastic!

One week ago I started (not sent) a mail that was intended for you on
python(x,y)
I explained that the main issue I get with users I want to convert to python
is:
1) Hey there is so lot packages, each time I need to install a new package
to get your feature.
2) Python is bad for my dumb users, scilab is better, when they double
click on the .sce it open the script, they edit the parameters in the script
file and run the script clicking on run.

Python(x,y) solved point 1. Pydee could solve point 2! 
Perhaps I will be able to trash these ## install of scilab!

Have you planed to integrate it into python(x,y)? If yes, an excellent idea
could be to be able to create file extension like .pyp that are python
script but that open Pydee!

Wow I had seen your pyqtshell I was really impressed by all the surrounding
widgets. 
Wow ;)

Good job! :)



--
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] imshow update norm make my app crash.

2008-07-29 Thread Laurent Dufrechou
Hi guys, continuing exploring matplotlib capabilities J

 

I've applied the idea you've said later about colormap.

Now I would like on an event to refresh my view so I've written this code:

 

   .

 

   def InitCode(self):

.

self.norm = plt.Normalize(vmin=0, vmax=255)

self.cmap = cm.jet

im_full = full_sonar.imshow( z, aspect= 'auto', cmap=self.cmap,
norm=self.norm, interpolation='quadric')

im_zoom = zoomed_sonar.imshow( z, aspect= 'auto',cmap=self.cmap,
norm=self.norm, interpolation='quadric')

 
self.fig.colorbar(im_full,cax=cax,orientation='vertical',extend='both')

self.im_full = im_full

self.im_zoom = im_zoom

.



def updateSonarView(self):

self.im_full.set_cmap(self.cmap)

self.im_zoom.set_cmap(self.cmap)

self.im_full.set_norm(self.norm)

self.im_zoom.set_norm(self.norm)

self.fig.canvas.draw()



def OnUpdateButton(self, event):

self.low_clutter_val = self.clutter_low.GetPosition()

self.high_clutter_val = self.clutter_high.GetPosition()

self.norm = plt.Normalize(vmin=self.low_clutter_val,
vmax=self.high_clutter_val)

self.updateSonarView()

 

But I get this error from the lib :

 

Traceback (most recent call last):

  File ./Filters\A1Filter.py, line 183, in OnUpdateButton

self.updateSonarView()

  File ./Filters\A1Filter.py, line 157, in updateSonarView

self.im_full.set_norm(self.norm)

  File C:\Python25\Lib\site-packages\matplotlib\cm.py, line 129, in
set_norm

self.changed()

  File C:\Python25\Lib\site-packages\matplotlib\image.py, line 123, in
changed

cm.ScalarMappable.changed(self)

  File C:\Python25\Lib\site-packages\matplotlib\cm.py, line 174, in
changed

self.callbacksSM.process('changed', self)

  File C:\Python25\Lib\site-packages\matplotlib\cbook.py, line 152, in
process

func(*args, **kwargs)

  File C:\Python25\Lib\site-packages\matplotlib\figure.py, line 1028, in
on_changed

cb.update_bruteforce(m)

  File C:\Python25\Lib\site-packages\matplotlib\colorbar.py, line 649, in
update_bruteforce

self.draw_all()

  File C:\Python25\Lib\site-packages\matplotlib\colorbar.py, line 221, in
draw_all

self._process_values()

  File C:\Python25\Lib\site-packages\matplotlib\colorbar.py, line 458, in
_process_values

b = self.norm.inverse(self._uniform_y(self.cmap.N+1))

  File C:\Python25\Lib\site-packages\matplotlib\colors.py, line 652, in
inverse

return vmin + val * (vmax - vmin)

  File C:\Python25\Lib\site-packages\numpy\ma\core.py, line 1686, in
__mul__

return multiply(self, other)

  File C:\Python25\Lib\site-packages\numpy\ma\core.py, line 503, in
__call__

result = self.f(d1, d2, *args, **kwargs).view(get_masked_subclass(a,b))

ValueError: shape mismatch: objects cannot be broadcast to a single shape

 

UpdateSonarview works flawlessly if I modify the colormap (self.cmap) and
call it then.

If I modify self.norm and call UpdateSonarView I get this crash.

 

Is it a bug from my bad usage of the lib? If not, I can perhaps send you a
stripped down file showing the problem?

Using matplotlib 0.98.1 under windows.

 

Laurent

-
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] Colormap cluttering?

2008-07-28 Thread Laurent Dufrechou
Hello,

 

I would like to have a cluttering functionality to colorbar.

http://en.wikipedia.org/wiki/Clutter_(radar)

 

Before writing it, I would like to know if there is a way to doing it with
matplotlib.

What I mean by cluttering is:

 

You've got a colormap associated with a graphic where value goes from 0 to
255 for example.

Assigning a classical colormap (for example cm.jet) 0 value will be blue and
255 one will be red.

What I need is a low  clutter and max clutter, if I set low clutter to 10
and ax cluter to 250 then:

Blue will be for value from 0 to 10

Then the colormap do his job from 10 to 250 and finally 

From 250 to 255 colr will be set to max one = red.

 

Is it ever done in matplotlib, if not what could be the strategy here.?

I was thinking of set_over/set_under but seems not be exactly what I need
because I want to recreate the colormap from 10 to 250 with N segments.

(moreover I don't understand how you set the over/under value.)

 

Laurent

-
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] Problem with wxAgg toolbar and py2exe

2008-07-07 Thread Laurent Dufrechou
Hello,

I've recently used the toolbar from wxAgg backend:

from matplotlib.backends.backend_wx import NavigationToolbar2Wx

 

I've got a problem when trying to freeze my app now because I get this
message when trying to invoke the toolbar:

 

Traceback (most recent call last):

  File CommandPanel.pyo, line 80, in OnOpenFile

  File AnalystPanel.pyo, line 33, in addPanel

  File Filter.pyo, line 50, in createWidget

  File A1Filter.pyo, line 70, in fillWidget

  File matplotlib\backends\backend_wx.pyo, line 1548, in __init__

  File matplotlib\backend_bases.pyo, line 1524, in __init__

  File matplotlib\backends\backend_wx.pyo, line 1570, in _init_toolbar

  File matplotlib\backends\backend_wx.pyo, line 1405, in _load_bitmap

IOError: Could not find bitmap file mpl-data\images\home.png; dying

 

It is really strange because I've put this in my setup.py:

import matplotlib

data_files = matplotlib.get_py2exe_datafiles()

 

So there is a directory mpl-data/images so should work.

(other files are well found like fonts etc.)

Any guys has had this issue? (Matplotlib 0.98.1)

 

Laurent

 

-
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] [wxpython-users] Controlling the wxpython matplotlib-frame

2008-03-27 Thread Laurent Dufrechou
Have you tryied : ipython -pylab ?
It launch an ipython shell that support mathplotlib gui loop.

-Message d'origine-
De : [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]
] De la part de Wolfgang Kerzendorf
Envoyé : mercredi 26 mars 2008 08:31
À : matplotlib-users@lists.sourceforge.net;
[EMAIL PROTECTED]
Objet : [wxpython-users] Controlling the wxpython matplotlib-frame

Hello all,
I have trouble with one of my scripts that uses matplotlib when using  
python or ipython. The first time it opens, it does not hand the  
control back o the shell and can be used to work on the matplotlib  
figure interactively (I use an event handler and picker objects to  
change my plots) so it works really well. After I close the window the  
control is given back to the shell. This is how I want it to work,  
however at the second time the matplotlib plot opens the shell does  
not stop anymore, the script continues. When I used GTKAgg on my old  
linux box I had the same issue and bound a key to  
pylab.get_current_figure_manager().destroy(), which looked like a hack  
to me but  worked. This does not work anymore with wxPython, because  
the next time I open a plot I get an exception:

PyDeadObjectError: The C++ part of the FigureFrameWxAgg object has  
been deleted, attribute access no longer allowed.

I also think destroying the figure_manager is not the right way to do  
that. Whats a goog solution for this?
Thanks in advance
 Wolfgang

P.S.: I know I posted a similar thing yesterday, but I thought  
rephrasing the question might help with finding the solution
___
wxpython-users mailing list
[EMAIL PROTECTED]
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users


-
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users