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
Plot raw data Points with wxPlotCtrl Topic is solved
-
- I live to help wx-kind
- Posts: 178
- Joined: Mon Jul 23, 2007 9:01 am
-
- I live to help wx-kind
- Posts: 178
- Joined: Mon Jul 23, 2007 9:01 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
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
In plotctrl.h:
So, you'd have to do something like this:
hope this helps a bit
best regards,
fantaz
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); }
...
Code: Select all
m_plotCtrl->SetDrawLines(false);
m_plotCtrl->SetDrawSymbols(true);
best regards,
fantaz
-
- I live to help wx-kind
- Posts: 178
- Joined: Mon Jul 23, 2007 9:01 am
Re: Plot raw data Points with wxPlotCtrl
I cant draw raw points! the code im trying is:
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!
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);
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!