473,703 Members | 2,371 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

wxpython, updating plot (wx.lib.plot)

75 New Member
Hi! I just moved using wxpython so I'm a quite newbie.

I was wondering how to update plotcanvas?
In my code I made button with event to update plotcanvas with new results, but how to properly do it? because now when I press button it makes new "layer" into my GUI and doesn't delete the old plot. Should I first delete the old one and then create new plot, or just update old one, well either way I don't know how to do it... =/

Expand|Select|Wrap|Line Numbers
  1. #!/usr/bin/env python
  2. # -*- coding: UTF-8 -*-
  4. import wx
  5. import wx.lib.plot as plot
  7. class MyFrame(wx.Frame):
  8.     def __init__(self):
  9.         self.frame1 = wx.Frame(None, title="test", id=-1, size=(500, 300))
  10.         self.panel1 = wx.Panel(self.frame1)
  11.         self.panel1.SetBackgroundColour("white")
  13.         Button1 = wx.Button(self.panel1, -1, "Update", (200,220))
  14.         Button1.Bind(wx.EVT_BUTTON, self.redraw)
  16.         plotter = plot.PlotCanvas(self.panel1)
  17.         plotter.SetInitialSize(size=(500, 200))
  19.         data = [[1, 10], [2, 5], [3, 10], [4, 5]]
  20.         line = plot.PolyLine(data, colour='red', width=1)
  22.         gc = plot.PlotGraphics([line], 'Test', 'x', 'y')
  23.         plotter.Draw(gc)
  25.         self.frame1.Show(True)
  28.     def redraw(self, event):
  29.         plotter = plot.PlotCanvas(self.panel1)
  30.         plotter.SetInitialSize(size=(500, 200))
  32.         data2 = [[1, 20], [2, 15], [3, 20], [4, -10]]
  33.         line = plot.PolyLine(data2, colour='red', width=1)
  35.         gc = plot.PlotGraphics([line], 'Test', 'x', 'y')
  36.         plotter.Draw(gc)
  38. app = wx.PySimpleApp()
  39. f = MyFrame()
  40. app.MainLoop()
Jun 17 '08 #1
1 8339
314 Contributor
plotter.Clear() should take care of clearing the canvas.

I've only used matplotlib before; and I know that in order to get a dynamic plot up and running I had to use clear before every new plot. I assume it would be similar with wx.lib.plot
Jun 17 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

by: Steve Lamb | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Ok, this one I did try before coming here... :) I am trying to report the status of what is going on to the status bar of the main window of my wxPython app. I know I'm on the right track with SetStatusText() but it doesn't always alter the text. What the program is doing is taking a filename and passing it through two different external programs. One of them is taking a little bit of...
by: Oh Kyu Yoon | last post by:
Does anyone know how to implement plots from scipy, chaco, etc into wxPython widget? Thank you
by: Jan Danielsson | last post by:
Hello all, I wanted to plot some statistics, so I wrote a simple wxPython class to do it. Then I realized that I would like to draw bar graphs, so I added that too. Since I'm a complete Python newbie, I haven't done much of it the "Python way", I suspect. So, I'm wondering if someone would like to show me some of the tricks I should have used.
by: ajikoe | last post by:
Hello, I make a windows button which show pylab plot. When I click the button the plot is showed, then I close the plot. But the second click will always produce the plot (which can't be closed). Can someone help? pujo
by: KvS | last post by:
Hi all, I'm pretty new to (wx)Python so plz. don't shoot me if I've missed something obvious ;). I have a panel inside a frame, on which a Button and a StaticText is placed: self.panel = wx.Panel(self,-1) self.button = wx.Button(self.panel,-1,"Klikkerdeklik") self.button.SetPosition((200,40)) self.Bind(wx.EVT_BUTTON, self.VeranderLabel, self.button)
by: Robin Dunn | last post by:
Announcing ---------- The release of wxPython is now available for download at http://wxpython.org/download.php. There have been many enhancements and fixes implemented in this version, many of which are listed below and at http://wxpython.org/recentchanges.php. What is wxPython?
by: Robin Dunn | last post by:
Announcing ---------- The release of wxPython is now available for download at http://wxpython.org/download.php. There have been many enhancements and fixes implemented in this version, many of which are listed below and at http://wxpython.org/recentchanges.php. What is wxPython?
by: Soren | last post by:
Hi, I'm trying to create a small GUI program where I can do plots using Matplotlib. I've been trying to borrow code from the examples at the matplotlib website, but I can't get it to work. I want to be able to create a wx.Panel that contains an axis for plotting. Around it i want other panels containing various settings, buttons etc. to control the plot. So far I can't even get the program to actually show a plot in a panel.
by: Soren | last post by:
Hi, I've been trying to embed matplotlib in wxpython. I want to be able to put a figure (axes) in a wx.Panel and place it somewhere in my GUI. The GUI should have other panels with buttons etc. that can control the output on the figure. I've been looking at the examples from the matplotlib website, but can't seem to get it to work.. Does anyone here have experience in embedding matplotlib in wxpython?
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.