コードはこんな感じ
protected void SaveGraph( String filename )
{
int count = this.pos.Count;
int [] source = new int[count];
int [] dist = new int[count];
int posIndex;
for (posIndex = 0; posIndex < count; posIndex++)
{
source[posIndex] = (int)altitude[posIndex];
dist[posIndex] = (int)distance[posIndex];
}
Bitmap bitmap = new Bitmap(700, 300);
Graphics g = Graphics.FromImage(bitmap);
g.FillRectangle(Brushes.White, 0, 0, bitmap.Width, bitmap.Height );
NPlot.Bitmap.PlotSurface2D surface = new PlotSurface2D(bitmap);
NPlot.StepPlot plot = new NPlot.StepPlot();
plot.Pen.Color = Color.FromArgb(16, 128, 255);
plot.DataSource = source;
plot.AbscissaData = dist;
surface.Add(plot);
surface.YAxis1.WorldMin = 0;
surface.YAxis1.Label = "高度 (m)";
surface.XAxis1.Label = "走行距離 (m)";
surface.Refresh();
bitmap.Save( filename, ImageFormat.Jpeg );
}
結果はこんな感じ
ログはこんな感じ