/* From: "COMPUTATIONAL PHYSICS, 2nd Ed" by RH Landau, MJ Paez, and CC Bordeianu Copyright Wiley-VCH, 2007. Electronic Materials copyright: R Landau, Oregon State Univ, 2007; MJ Paez, Univ Antioquia, 2007; and CC Bordeianu, Univ Bucharest, 2007. Support by National Science Foundation */ // EasyPtPlot.java: Simple PtPlot application import ptolemy.plot.*; public class EasyPtPlot { public static final double Xmin = -5., Xmax = 5.; // Graph domain public static final int Npoint = 500; public static void main(String[] args) { Plot plotObj = new Plot(); // Create Plot object plotObj.setTitle("f(x) vs x"); plotObj.setXLabel("x"); plotObj.setYLabel("f(x)"); // plotObj.setSize(400, 300); // plotObj.setXRange(Xmin, Xmax); // plotObj.addPoint(int Set, double x, double y, boolean connect) double xStep = (Xmax - Xmin) / Npoint; // Plotting loop for ( double x = Xmin; x <= Xmax; x += xStep) { double y = Math.sin(x)*Math.sin(x); plotObj.addPoint(0, x, y, true); } PlotApplication app = new PlotApplication(plotObj); // Display } }