-
Notifications
You must be signed in to change notification settings - Fork 73
/
example2.cpp
49 lines (40 loc) · 1.29 KB
/
example2.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include "pbPlots.hpp"
#include "supportLib.hpp"
using namespace std;
int main(){
bool success;
StringReference *errorMessage = CreateStringReferenceLengthValue(0, L' ');
RGBABitmapImageReference *imageReference = CreateRGBABitmapImageReference();
vector<double> xs{-2, -1, 0, 1, 2};
vector<double> ys{2, -1, -2, -1, 2};
ScatterPlotSeries *series = GetDefaultScatterPlotSeriesSettings();
series->xs = &xs;
series->ys = &ys;
series->linearInterpolation = true;
series->lineType = toVector(L"dashed");
series->lineThickness = 2;
series->color = GetGray(0.3);
ScatterPlotSettings *settings = GetDefaultScatterPlotSettings();
settings->width = 600;
settings->height = 400;
settings->autoBoundaries = true;
settings->autoPadding = true;
settings->title = toVector(L"x^2 - 2");
settings->xLabel = toVector(L"X axis");
settings->yLabel = toVector(L"Y axis");
settings->scatterPlotSeries->push_back(series);
success = DrawScatterPlotFromSettings(imageReference, settings, errorMessage);
if(success){
vector<double> *pngdata = ConvertToPNG(imageReference->image);
WriteToFile(pngdata, "example2.png");
DeleteImage(imageReference->image);
}else{
cerr << "Error: ";
for(wchar_t c : *errorMessage->string){
wcerr << c;
}
cerr << endl;
}
FreeAllocations();
return success ? 0 : 1;
}