01 /*
02 * $Id: SubPlot.java,v 1.8 2008/02/02 03:06:29 koga Exp $
03 *
04 * Copyright (C) 2004 Koga Laboratory. All rights reserved.
05 *
06 */
07 package matxbook.chap12old;
08
09 import org.mklab.nfc.matrix.DoubleMatrix;
10 import org.mklab.nfc.matrix.misc.LinearlySpacedVector;
11 import org.mklab.tool.graph.mgplot.Mgplot;
12
13
14 /**
15 * 複数のキャンバスにグラフを描画するサンプルです。
16 * @author koga
17 * @version $Revision: 1.8 $, 2004/05/01
18 */
19 public class SubPlot {
20
21 /**
22 * メインメソッド
23 *
24 * @param args コマンドライン引数
25 * @throws InterruptedException 強制終了された場合
26 */
27 public static void main(String[] args) throws InterruptedException {
28 DoubleMatrix w = LinearlySpacedVector.create(-Math.PI, Math.PI);
29 DoubleMatrix s = w.sinElementWise();
30 DoubleMatrix c = w.cosElementWise();
31 Mgplot.subplot(1, 2, 2, 1);
32 Mgplot.plot(1, w, s, new String[] {"sin(x)"}); //$NON-NLS-1$
33 Mgplot.subplot(1, 2, 2, 2);
34 Mgplot.plot(1, w, c, new String[] {"cos(x)"}); //$NON-NLS-1$
35 Mgplot.subplot(1, 2, 2, 3);
36 Mgplot.plot(1, w, s.multiply(2), new String[] {"2*sin(x)"}); //$NON-NLS-1$
37 Mgplot.subplot(1, 2, 2, 4);
38 Mgplot.plot(1, w, c.multiply(2), new String[] {"2*cos(x)"}); //$NON-NLS-1$
39 Thread.sleep(10000);
40 Mgplot.quit();
41 }
42 }
|