Re: [Matplotlib-users] Clear Figure

2008-10-05 Thread rocha

Hi Jae-Joon Lee,

I tried it but unfortunately it didn't work too. After the Figure is 
cleared I cannot plot again.


I've attached the whole code that I'm trying to do this, I hope it could 
help a little bit. I modified the original example just to test this 
feature.


Thanks!
Bernardo M. Rocha

Jae-Joon Lee wrote:

I guess you need to put draw() after plot()

self.canvas.figure.clf()
self.canvas.axes.plot([1.,2.,4.])
self.canvas.draw()

Let us know if it does not help.

-JJ



On Sat, Oct 4, 2008 at 7:17 PM, rocha <[EMAIL PROTECTED]> wrote:
  

Hi Guys,

I need to clear the Figure after the user has clicked the some button in
PyQt, but when I try to plot the graphics again nothing appear. In
ipython it works, but when I try it inside my application it does not
work. What am I missing?

Inside my MplCanvas class (actually it is a QWidget - see
embedding_in_qt4.py in matplotlib examples file - user_interface) I have
this code:

self.fig = Figure(figsize=(self.width, self.height), dpi=dpi)

And then in my main application I'm trying to do:

self.canvas.figure.clf()
self.canvas.draw()
self.canvas.axes.plot([1.,2.,4.])

and nothing is plotted. The Figure is totally gray. I tried to do the
same thing in embedding_in_qt4.py example, modifying some parts, but it
didn't work too.

Do you have any suggestions?

Thanks!
Best regards,
Bernardo M. Rocha

-
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=100&url=/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users




#!/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()

def limpa(self):
self.figure.clf()
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.file_menu = QtGui.QMenu('&File', self)
self.file_menu.addAction('&Quit', self.fileQuit,
 QtCore.Qt.CTRL + QtCore.Qt.Key_Q)
self.menuBar().addMenu(self.file_menu)

self.help_menu = QtGui.QMenu('&Help', self)
se

[Matplotlib-users] Clear Figure

2008-10-04 Thread rocha
Hi Guys,

I need to clear the Figure after the user has clicked the some button in 
PyQt, but when I try to plot the graphics again nothing appear. In 
ipython it works, but when I try it inside my application it does not 
work. What am I missing?

Inside my MplCanvas class (actually it is a QWidget - see 
embedding_in_qt4.py in matplotlib examples file - user_interface) I have 
this code:

self.fig = Figure(figsize=(self.width, self.height), dpi=dpi)  

And then in my main application I'm trying to do:

self.canvas.figure.clf()
self.canvas.draw()
self.canvas.axes.plot([1.,2.,4.])

and nothing is plotted. The Figure is totally gray. I tried to do the 
same thing in embedding_in_qt4.py example, modifying some parts, but it 
didn't work too.

Do you have any suggestions?

Thanks!
Best regards,
Bernardo M. Rocha

-
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=100&url=/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] matplotlib qt4 backend: QScrollArea

2008-09-11 Thread bernardo martins rocha
Hi everyone,

I would like to create a plot in matplotlib using a lot of subplots but 
I would like to attach QScrollArea to this. Do you guys have any idea of 
how can I do it? I did it with an image but it doesn't work when I try 
to include the FigureCanvas object to the QScrollArea.

Thanks!
Bernardo M. Rocha

-
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=100&url=/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] size of the plot

2008-09-08 Thread Bernardo Martins Rocha
Hi Guys,

how can I set the size of a plot window by, let's say, 320 x 180 and make it 
fix, that is, something like "resize=False". I had a look at the documentation 
but I couldn't figure out which object and method I have to use for this.

Thanks in advance!
Bernardo M. Rocha

-
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=100&url=/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] axis and zoom

2008-09-02 Thread bernardo martins rocha
Hi Guys,

I have some questions:

1. How can I zoom in the horizontal axis and maintain the vertical axis 
unchanged with the zoom tool provided by matplotlib?

2. How can I change the xticks so that they do not overlap each other? 
For instance, I have a plot in time, but since it's a huge simulation 
the time ticks 2000 3000 are overlapping, so that I cannot understand. 
Is it possible to change the units? Like 2 3 and then add 10^3 somewhere 
else? I hope you can understand my question...sorry if it's not clear.

Bernardo M. Rocha






-
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=100&url=/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users