Plot raw data Points with wxPlotCtrl  [SOLVED]

Talk here about issues with one of the components hosted at wxCode, or suggest features for it.
orbitcowboy
I live to help wx-kind
I live to help wx-kind
Posts: 178
Joined: Mon Jul 23, 2007 9:01 am

Plot raw data Points with wxPlotCtrl

Postby orbitcowboy » Tue Aug 21, 2007 12:10 pm

Hi @all,

is it possible to draw a set of raw data points with wxPlotCtrl?
I 've just found the wxPlotCtrl::AddCurve(...) function , drawing an interpolated function of the given datapoints. In my Application i want to draw a set of points.... can anybody help me?

Regards

Orbitcowboy

timg
Earned some good credits
Earned some good credits
Posts: 148
Joined: Mon Jan 23, 2006 6:52 pm

Postby timg » Tue Aug 21, 2007 6:09 pm

you need to create a wxPlotData and add that.

wxPlotData is for plotting points.

orbitcowboy
I live to help wx-kind
I live to help wx-kind
Posts: 178
Joined: Mon Jul 23, 2007 9:01 am

Postby orbitcowboy » Wed Aug 22, 2007 8:54 am

thanks for your answer but,

m_PlotCtrl = new wxPlotCtrl(this,wxID_ANY);

wxPlotData *m_PlotData = new wxPlotData(1000,true);

for(int iIndex = 0; iIndex < 1000; iIndex ++)
{
m_PlotData->SetXValue(iIndex,cos(static_cast<double>(iIndex)));
m_PlotData->SetYValue(iIndex,-sin(static_cast<double>(iIndex)));

}
if(m_PlotData->Ok())
{ m_PlotCtrl->AddCurve(m_PlotData, true, true);}

by plotting this points, the genereted points are interpreted as a function. Question: Is it possible to draw just the raw points (without interpolation)?

I need this in my application, because i intend to display a matrix with data points, simply like this:
e.g:
y
^
| 0 0 0 1 0 0 1 0 0 0
| 1 0 0 1 0 0 1 0 1 0
| 0 0 0 1 0 0 1 0 0 0
| 0 0 0 1 0 0 1 0 1 0
| 1 0 0 1 0 0 1 0 0 0
--------------------->x

all the values '1' whould be drawn as point.

Regards

Orbitcowby

fantaz
I live to help wx-kind
I live to help wx-kind
Posts: 169
Joined: Mon Sep 13, 2004 10:07 am
Location: Croatia

  [SOLVED]

Postby fantaz » Wed Aug 22, 2007 9:25 am

In plotctrl.h:

Code: Select all

 ...
// Draw the data curve symbols on the plotctrl
    bool GetDrawSymbols() const { return m_draw_symbols; }
    void SetDrawSymbols( bool drawsymbols = true )
        { m_draw_symbols = drawsymbols; Redraw(wxPLOTCTRL_REDRAW_PLOT); }

    // Draw the interconnecting straight lines between data points
    bool GetDrawLines() const { return m_draw_lines; }
    void SetDrawLines( bool drawlines = true )
        { m_draw_lines = drawlines;
Redraw(wxPLOTCTRL_REDRAW_PLOT); }
...

So, you'd have to do something like this:

Code: Select all

m_plotCtrl->SetDrawLines(false);
m_plotCtrl->SetDrawSymbols(true);

hope this helps a bit
best regards,
fantaz

orbitcowboy
I live to help wx-kind
I live to help wx-kind
Posts: 178
Joined: Mon Jul 23, 2007 9:01 am

Postby orbitcowboy » Wed Aug 22, 2007 10:18 am

Great!Thanks for your help!

Orbitcowboy

Agucho
Earned a small fee
Earned a small fee
Posts: 14
Joined: Sat Jul 09, 2011 8:20 pm

Re: Plot raw data Points with wxPlotCtrl

Postby Agucho » Sun Jul 17, 2011 10:12 pm

I cant draw raw points! the code im trying is:

Code: Select all

Grafica1->DeleteCurve(-1,false);
    Grafica1->SetDrawLines(false);
    Grafica1->SetDrawSymbols(true);
    Grafica1->SetZoom(0,0,1,1,false);

    int x1=5,x2=7;
    int y1=6,y2=4;
    int range=2;
    wxPlotData *data_dir=new wxPlotData(range,false);
    data_dir->SetValue(0,x1,y1);
    data_dir->SetValue(1,x2,y2);
    wxGenericPen pen(wxGenericColour(220, 20, 60));
    data_dir->SetPen(wxPLOTPEN_NORMAL, pen);
    Grafica1->AddCurve((const wxPlotData&)*data_dir,false,false);
   
    Grafica1->Redraw(wxPLOTCTRL_REDRAW_PLOT);


Grafica1 is my wxPlotCtrl.

Please explain me how to draw raw points because with this code I only hace a diagonal line, and if i only try to draw a single point i also have a line between the point i define and the origin.
Thanks!


Return to “wxCode”

Who is online

Users browsing this forum: No registered users and 2 guests