PtPlot: 2D Graphs within Java
Rubin H. Landau, Manuel José Páez, Cristian C. Bordeianu · 2007
A PtPlot: 2D Graphs within JavaPtPlot is an excellent plotting package that lets you plot directly from your Java programs.PtPlot is free, written in Java (and thus runs under Unix, Linux, Mac OS, and MS Windows), is easy to use, and is actually part of Ptolemy, an entire computing environment that is supported by the University of California. Figure A.1 is an example of a PtPlot graph.Because PtPlot is not built into Java, your Java program needs to import the PtPlot package and work with its classes.We suggest that you download the most recent version over the Web.Fig. A.1 Sample output from PtPlot in which three data sets are placed on one plot.Observe the error bars on two of the sets.The program EasyPtPlot.java in Listing A.1 is an example of a how to construct a simple graph of cos(x) versus x with PtPlot.On line 2 we see the statement import ptolemy.plot.* ; that imports the PtPlot classes.(In order for this to work for you, you may have to modify your CLASSPATH environmental variable.)PtPlot represents your plot as a Plot object, which we name myPlot and create on line 7.We then add various features, step by step, to myPlot to make it just the plot we want.As is standard with objects in Java, we first give the name of the object and then modify it with "dot modifiers."Rather than tell PtPlot what ranges for x and y to plot, we let PtPlot set the x and y ranges based on the data it is given.By having true as the fourth ar-Computational P hysics