01 /*
02 * $Id: ExportFig.java,v 1.11 2008/02/02 03:06:27 koga Exp $
03 *
04 * Copyright (C) 2004 Koga Laboratory. All rights reserved.
05 *
06 */
07 package matxbook.chap12;
08
09 import java.io.IOException;
10
11 import org.mklab.nfc.matrix.DoubleMatrix;
12 import org.mklab.nfc.util.Pause;
13 import org.mklab.tool.graph.gnuplot.Canvas;
14 import org.mklab.tool.graph.gnuplot.Gnuplot;
15
16
17 /**
18 * グラフをFigフォーマットで出力するサンプルです。
19 * @author koga
20 * @version $Revision: 1.11 $, 2004/05/01
21 */
22 public class ExportFig {
23
24 /**
25 * メインメソッド
26 *
27 * @param args コマンドライン引数
28 * @throws InterruptedException 強制終了された場合
29 * @throws IOException キーボードから入力できない場合
30 */
31 @SuppressWarnings("nls")
32 public static void main(String[] args) throws InterruptedException, IOException {
33 DoubleMatrix t = DoubleMatrix.series(0, 2 * Math.PI, 0.1);
34 DoubleMatrix s = t.sinElementWise();
35 DoubleMatrix c = t.cosElementWise();
36 Gnuplot gnuplot = new Gnuplot();
37 Canvas canvas = gnuplot.createCanvas();
38 canvas.plot(t, s.appendDown(c), new String[] {"sin(t)", "cos(t)"});
39 gnuplot.export("sin_cos.fig", "fig");
40 Pause.pause();
41 gnuplot.close();
42 }
43 }
|