PPlot mPPlot;
// make x/y datasets for one plotitem
PlotData *xdata = new PlotData ();
PlotData *ydata = new PlotData ();
// fill them as any stl container (with floats)
for (...) {
xdata->push_back (...);
ydata->push_back(...);
}
// add item to the plot
mPPlot.mPlotDataContainer.AddXYPlot (xdata, ydata);// takes ownership
PlotData *xdata1 = ...;// see above how to make two x/y datasets
PlotData *ydata1 = ...;
PlotData *xdata2 = ...;
PlotData *ydata2 = ...;
LegendData *legend1 = new LegendData ();// let us setup the first legend
legend1->mName = "foo";
legend1->mColor = PColor (100,200,200);// just an rgb value
LegendData *legend2 = ...;// do something similar for the second legend
// add the plotitems
mPPlot.mPlotDataContainer.AddXYPlot (xdata1,ydata1, legend1);
mPPlot.mPlotDataContainer.AddXYPlot (xdata2,ydata2, legend2);
mPPlot.mMargins.mLeft = 20;
mPPlot.mMargins.mRight = 20;
mPPlot.mMargins.mTop = 20;
mPPlot.mMargins.mBottom = 20;
mPPlot.mXAxisSetup;You can turn of autoscaling and provide a customized range for an axis (for instance the x axis) like this
mPPlot.mYAxisSetyp;
mPPlot.mXAxisSetup.SetAutoScale (false);You can use autoscale to the maximum of your data but keep the minimum at a fixed value like this
mPPlot.mXAxisSetup.mMin = -5;
mPPlot.mXAxisSetup.mMax = 3;
mPPlot.mXAxisSetup.mAutoScaleMin = false;// do not change the minumumLogarithmic scale is achieved with
mPPlot.mXAxisSetup.mMin = 0;
mPPlot.mXAxisSetup.mAutoScaleMax = true;// do change the maximum according to data
mPPlot.mXAxisSetup.mLogScale = true;By default an axis goes through the origin. As a result it may become invisible. You can prevent this with
mPPlot.mXAxisSetup.mLogBase = 10;// 10 is the default
mPPlot.mXAxisSetup.mCrossOrigin = false;// this way the axis will always be visibleYou can give the axis a label with
mPPlot.mXAxisSetup.mLabel = "bar";To change the direction in which the data run with respect to screen coordinates you can specify
mPPlot.mXAxisSetup.mAscending=true;// default: left is minimum, right is maximum
mPPlot.mYAxisSetup.mAscending=false;// default : bottom is minimum, top is maximum
mPPlot.mPlotBackground.mTitle = "nice curves";
mPPlot.mPlotBackground.mTransparent = false;
mPPlot.mPlotBackground.mPlotRegionBackColor = PColor (3,100,130);
mPPlot.mGridInfo.mXGridOn = true;
mPPlot.mGridInfo.mYGridOn = true;
PlotData *theYData = ...An even more simple solution is to supply a null value as xdata
// fill ydata here
DummyData *theXData = new DummyData (theYData->size ());// make the indexed data
mPPlot.mPlotDataContainer.AddXYPlot (theXData, theYData);
mPPlot.mPlotDataContainer.AddXYPlot (0, theYData);
StringData *theStringData = new StringData ();the end.
for () {
theStringData->AddItem ("string i here");
}