Exemple #1
0
void TestAxisLabels()
{
    
    CPlot2D *plot2D=new CPlot2D();
    
    CDataSet dataSet;
    CDataPoint point;
    
    
    for (double x=-100.01;x<=100.0;x+=10.0) {
        point.SetValues(x,x*x*x-x*x+x);
        dataSet.AddDataPoint(point);
    }
    
    
    dataSet.SetDatasetColor(0.0,1.0,0.0);
    dataSet.SetDatasetTitle("x^3-x^2+x");
    plot2D->AddDataSet(dataSet);
    
    plot2D->SetXAxisTitle("x axis");
    plot2D->SetYAxisTitle("y=x^3-x^2+x axis");
    
    plot2D->SetLeftFrameSize(100.0);
    
    plot2D->OutputPostScriptPlot("test5_axis_labels.ps");
    
}
Exemple #2
0
void TestTrigFunctions()
{
    CPlot2D *plot2D=new CPlot2D();
    
    CDataSet dataSet;
    
    CDataPoint point;
    
    for (double x=-3.1515;x<=3.2;x+=0.1) {
        point.SetValues(x,sin(x));
        dataSet.AddDataPoint(point);
    }
    dataSet.SetDatasetColor(0.0,0.0,0.0);
    dataSet.SetDatasetTitle("sin(x)");
    
    plot2D->AddDataSet(dataSet);
    
    
    CDataSet dataSet1;
    
    for (double x=-3.1515;x<=3.2;x+=0.1) {
        point.SetValues(x,cos(x));
        dataSet1.AddDataPoint(point);
    }
    dataSet1.SetDatasetColor(1.0,0.0,0.0);
    dataSet1.SetDatasetTitle("cos(x)");
    
    plot2D->AddDataSet(dataSet1);
    
    
    CDataSet dataSet2;
    
    for (double x=-3.1515;x<=3.2;x+=0.1) {
        point.SetValues(x,sin(x)*cos(x));
        dataSet2.AddDataPoint(point);
    }
    dataSet2.SetDatasetColor(0.0,0.0,1.0);
    dataSet2.SetDatasetTitle("sin(x)*cos(x)");
    
    plot2D->AddDataSet(dataSet2);
    
    plot2D->SetXAxisTitle("variable x");
    plot2D->SetYAxisTitle("function");
    
    plot2D->OutputPostScriptPlot("test1_trigfunctions.ps");
}