|
| 1 | +#include "pbPlots.h" |
| 2 | +#include "supportLib.h" |
| 3 | + |
| 4 | +int main(){ |
| 5 | + RGBABitmapImageReference *imageReference = CreateRGBABitmapImageReference(); |
| 6 | + |
| 7 | + double xs [] = {20.1, 7.1, 16.1, 14.9, 16.7, 8.8, 9.7, 10.3, 22, 16.2, 12.1, 10.3, 14.5, 12.4, 9.6, 12.2, 10.8, 14.7, 19.7, 11.2, 10.1, 11, 12.2, 9.2, 23.5, 9.4, 15.3, 9.6, 11.1, 5.3, 7.8, 25.3, 16.5, 12.6, 12, 11.5, 17.1, 11.2, 12.2, 10.6, 19.9, 14.5, 15.5, 17.4, 8.4, 10.3, 10.2, 12.5, 16.7, 8.5, 12.2}; |
| 8 | + double ys [] = {31.5, 18.9, 35, 31.6, 22.6, 26.2, 14.1, 24.7, 44.8, 23.2, 31.4, 17.7, 18.4, 23.4, 22.6, 16.4, 21.4, 26.5, 31.7, 11.9, 20, 12.5, 18, 14.2, 37.6, 22.2, 17.8, 18.3, 28, 8.1, 14.7, 37.8, 15.7, 28.6, 11.7, 20.1, 30.1, 18.2, 17.2, 19.6, 29.2, 17.3, 28.2, 38.2, 17.8, 10.4, 19, 16.8, 21.5, 15.9, 17.7}; |
| 9 | + |
| 10 | + double xs2 [] = {5, 25}; |
| 11 | + double ys2 [] = {12, 39}; |
| 12 | + |
| 13 | + ScatterPlotSeries *series = GetDefaultScatterPlotSeriesSettings(); |
| 14 | + series->xs = xs; |
| 15 | + series->xsLength = sizeof(xs)/sizeof(double); |
| 16 | + series->ys = ys; |
| 17 | + series->ysLength = sizeof(ys)/sizeof(double); |
| 18 | + series->linearInterpolation = false; |
| 19 | + series->pointType = L"dots"; |
| 20 | + series->pointTypeLength = wcslen(series->pointType); |
| 21 | + series->color = CreateRGBColor(1, 0, 0); |
| 22 | + |
| 23 | + ScatterPlotSeries *series2 = GetDefaultScatterPlotSeriesSettings(); |
| 24 | + series2->xs = xs2; |
| 25 | + series2->xsLength = sizeof(xs2)/sizeof(double); |
| 26 | + series2->ys = ys2; |
| 27 | + series2->ysLength = sizeof(ys2)/sizeof(double); |
| 28 | + series2->linearInterpolation = true; |
| 29 | + series2->lineType = L"solid"; |
| 30 | + series2->lineTypeLength = wcslen(series->lineType); |
| 31 | + series2->lineThickness = 2; |
| 32 | + series2->color = CreateRGBColor(0, 0, 1); |
| 33 | + |
| 34 | + ScatterPlotSettings *settings = GetDefaultScatterPlotSettings(); |
| 35 | + settings->width = 600; |
| 36 | + settings->height = 400; |
| 37 | + settings->autoBoundaries = true; |
| 38 | + settings->autoPadding = true; |
| 39 | + settings->title = L""; |
| 40 | + settings->titleLength = wcslen(settings->title); |
| 41 | + settings->xLabel = L""; |
| 42 | + settings->xLabelLength = wcslen(settings->xLabel); |
| 43 | + settings->yLabel = L""; |
| 44 | + settings->yLabelLength = wcslen(settings->yLabel); |
| 45 | + ScatterPlotSeries *s [] = {series, series2}; |
| 46 | + settings->scatterPlotSeries = s; |
| 47 | + settings->scatterPlotSeriesLength = 2; |
| 48 | + |
| 49 | + DrawScatterPlotFromSettings(imageReference, settings); |
| 50 | + |
| 51 | + size_t length; |
| 52 | + double *pngdata = ConvertToPNG(&length, imageReference->image); |
| 53 | + WriteToFile(pngdata, length, "example4.png"); |
| 54 | + DeleteImage(imageReference->image); |
| 55 | + |
| 56 | + return 0; |
| 57 | +} |
0 commit comments