data plot and interactive change

Hi,

I have question and want to see if it can be realized in wxpython.

I would like to plot data on wxpython, and then use the mouse to select some points which are plotted, and then move the mouse to manipulate those selected points, Then program use certain curve fitting to get a new modified curve.

Please let me know if there is any examples or suggestions can give the similar function in wxpython.

Regards!

zhengqing(Forrest)

Hi,
   I have question and want to see if it can be realized in wxpython.
   I would like to plot data on wxpython, and then use the mouse to select
some points which are plotted, and then move the mouse to manipulate those
selected points, Then program use certain curve fitting to get a new
modified curve.

of course it can be done with wxPython, but I supopse yopu'd rather
not write ALL teh code yourself.

   Please let me know if there is any examples or suggestions can give the
similar function in wxpython.

wx.lib.floatcanvas could help here.

There are a number of examples in SVN that aren't with teh demo. IN
particular, the "PolyEditor" demo should be helpful:

http://svn.wxwidgets.org/viewvc/wx/wxPython/3rdParty/FloatCanvas/Demos/PolyEditor.py?revision=51716&view=markup

I"d suggest:

* Create a new DrawObject for you fitted line, based on the Line
and/or Spline DrawObjects.

* Create a different drawobject for the "control points" of your line
-- based on the PointSet object.

* you should be able to link those tow together, so that your fitten
line uses the PointSet points (see the ConnectorLine Object in the
ProcessDiagram demo for an exampel of this)

* model your editing code off of the PolyEditor demo.

Post further questions to teh floatcanvas mailing list:

http://mail.paulmcnett.com/cgi-bin/mailman/listinfo/floatcanvas

-Chris

···

On Mon, Oct 1, 2012 at 4:09 PM, zhengqing <zhengqinggan@gmail.com> wrote:

-

Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov

If are not attached to the idea of 'interactive points', you could use matplotlib for the plotting, and then use other widgets to edit the data (maybe a wx.Grid?). After each edit, you would pass the data to the curve fit routine, and have the curve fit routine spit out the plot points.

···

On 10/1/2012 7:09 PM, zhengqing wrote:

Hi,
    I have question and want to see if it can be realized in wxpython.
    I would like to plot data on wxpython, and then use the mouse to select
some points which are plotted, and then move the mouse to manipulate those
selected points, Then program use certain curve fitting to get a new
modified curve.
    Please let me know if there is any examples or suggestions can give the
similar function in wxpython.

Regards!

zhengqing(Forrest)

Take a look at the PyPlot sample - a lot of what you are asking for is
already in there - draw plots, select points, etc., and it could
probably provide inspiration for how to do what you would like to do.

Gadget/Steve

···

On 02/10/2012 12:09 AM, zhengqing wrote:

Hi,
   I have question and want to see if it can be realized in wxpython.
   I would like to plot data on wxpython, and then use the mouse to
select some points which are plotted, and then move the mouse to
manipulate those selected points, Then program use certain curve
fitting to get a new modified curve.
   Please let me know if there is any examples or suggestions can give
the similar function in wxpython.

Regards!

zhengqing(Forrest)
--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

Actually, MPL does support event handling and picking, so you could do
the interactive points with that as well. If you want your plots
pretty and they are standard axes, etc, (i.e want other things MPL
give you) that's probably a good way to go.

Check out:

for a really cool example. (and you can learn a bit about basic
statistics as well)

-Chris

···

On Wed, Oct 3, 2012 at 5:36 AM, Benjamin Jessup <bsj@abzinc.com> wrote:

If are not attached to the idea of 'interactive points', you could use
matplotlib for the plotting, and then use other widgets to edit the data
(maybe a wx.Grid?). After each edit, you would pass the data to the curve
fit routine, and have the curve fit routine spit out the plot points.

--

Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov

Thank you very much for all your help.

just creat a demo using wx.lib.plot.

It works, and need to add a spline fitting function next.

I am not sure if this is a good way to write classes. Please let me know if there is any suggestion that can make the code clean and easy to read and follow.

Any book about good style of programming?

Regards!

zhengqing(Forrest)

wxPlotEditor.py (8.5 KB)

···

On Wednesday, October 3, 2012 9:26:27 AM UTC-7, Chris Barker wrote:

On Wed, Oct 3, 2012 at 5:36 AM, Benjamin Jessup b...@abzinc.com wrote:

If are not attached to the idea of ‘interactive points’, you could use
matplotlib for the plotting, and then use other widgets to edit the data
(maybe a wx.Grid?). After each edit, you would pass the data to the curve
fit routine, and have the curve fit routine spit out the plot points.

Actually, MPL does support event handling and picking, so you could do
the interactive points with that as well. If you want your plots
pretty and they are standard axes, etc, (i.e want other things MPL
give you) that’s probably a good way to go.

Check out:

http://www.youtube.com/watch?v=nCv_MhaeFo8

for a really cool example. (and you can learn a bit about basic
statistics as well)

-Chris

Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris....@noaa.gov

It works, and need to add a spline fitting function next.

wx.DC has a nifty spline drawing function, though you may want
something specific. I"d expect there is some coce out there for bezier
splines in numpy.python, though I haven't seen it.

I am not sure if this is a good way to write classes. Please let me know if
there is any suggestion that can make the code clean and easy to read and
follow.

some comments:

* don't use numpy.oldnumeric if you can help it (and you probably
can). And the standard way to import numpy these days is:

import numpy as np

"""data1 = 2.*_Numeric.pi*_Numeric.arange(200)/200.
    data1.shape = (100, 2)
    data1[:,1] = _Numeric.sin(data1[:,0])
"""

can (and probably should) be written something like:

t = np.linspace(0, np.pi, 100)
data1 = np.column_stack( (t, np.sin(t)) )

* I think I'd keep a PlotGraphics object around in your DrawData
class, and have the various methods modify it, rather than make a new
one each time. That way you can split out axis labeling, etc.

but it generally looks pretty good.

-Chris

···

On Wed, Oct 3, 2012 at 5:27 PM, zhengqing <zhengqinggan@gmail.com> wrote:

Any book about good style of programming?

Regards!

zhengqing(Forrest)

On Wednesday, October 3, 2012 9:26:27 AM UTC-7, Chris Barker wrote:

On Wed, Oct 3, 2012 at 5:36 AM, Benjamin Jessup <b...@abzinc.com> wrote:
> If are not attached to the idea of 'interactive points', you could use
> matplotlib for the plotting, and then use other widgets to edit the data
> (maybe a wx.Grid?). After each edit, you would pass the data to the
> curve
> fit routine, and have the curve fit routine spit out the plot points.

Actually, MPL does support event handling and picking, so you could do
the interactive points with that as well. If you want your plots
pretty and they are standard axes, etc, (i.e want other things MPL
give you) that's probably a good way to go.

Check out:

http://www.youtube.com/watch?v=nCv_MhaeFo8

for a really cool example. (and you can learn a bit about basic
statistics as well)

-Chris

--

Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris....@noaa.gov

--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

--

Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov

I used interpolate.UnivariateSpline from scipy

The smoothing looks better (is better controllable) than the built-in
PolySpline from wx.lib.plot

···

On Oct 4, 2:27 am, zhengqing <zhengqing...@gmail.com> wrote:

Thank you very much for all your help.
just creat a demo using wx.lib.plot.

It works, and need to add a spline fitting function next.