Plot.java
.
Ptplot is free for academic and commercial use. You an incorporate it into products, but you need to include follow the instructions in the copyright notice.
This copyright is based on the Tcl copyright that was used when Prof. Ousterhout was developing Tcl here at UC Berkeley. This copyright was also used in Ptolemy Classic, which has been used in commercial products.
If you use Ptplot in a product, and you would like us to include a pointer to your use in our Third Party uses of Ptplot page, then send email to ptplot at ptolemy eecs berkeley edu.
ptplot-announce
alias for announcing
new ptplot releases. This alias is for Ptplot announcements only. Thus,
you cannot post to this group. To subscribe to this group,
send email to ptplot-announce-request at ptolemy.eecs.berkeley.edu
with the word subscribe
in the body, not the header.
xgraph
and ptplot.
pxgraph
, an extension to xgraph
from
http://ptolemy.eecs.berkeley.edu/other/pxgraph.htm
http://ptolemy.eecs.berkeley.edu/ptolemyII/
.
We usually do a release of Ptolemy II once a year. As part of the Ptolemy II
release process, we usually do a standalone Ptplot release.
http://ptolemy.eecs.berkeley.edu/java/ptplot.htm
has links to the tar and zip files.
Java 1.4 or later is required, the PlotFrame class uses
import javax.print.attribute.PrintRequestAttributeSet; import javax.print.attribute.HashPrintRequestAttributeSet;These are part of the java.print package which does not exist in Java 1.3.1 or 1.3.2.
Ptplot will also work under Java 1.4.0, but note that Java 1.4.0 has a bug that prevents some applets from working well if Ptplot is installed in a directory that has spaces in the path name, see the troubleshooting page for details.
If you don't want to require your users to install the JDK plug-in, then try using Ptplot 3.1 or earlier.
A small standalone example that uses Ptplot 3.1 can be found at
http://ptolemy.eecs.berkeley.edu/java/ptplot/standalone/
Note that Ptplot 3.1 and later wll not compile with JDK1.1, the
Plot class uses the clear()
method from the Vector
class, which is not present in JDK1.1.
Ptplot 2.0 supported JDK1.1, and Ptplot 1.3 and earlier
supported JDK1.0.2, you can find those releases in
http://ptolemy.eecs.berkeley.edu/java/old
.
http://www.javasoft.com
.
See the Installing Ptplot page for more information
You can also run Ptplot as an applet in your local browser by downloading the Java Plug-in.
You might find useful information on the Ptplot homepage at
http://ptolemy.eecs.berkeley.edu/java/ptplot
.
If you are really stumped, you can send mail to ptplot at ptolemy eecs berkeley edu. Your mail should include:
Plot.java
file.
XTicks: Jan 0, Feb 31, Mar 59, Apr 90, May 120To handle time, once can convert to the number of minutes or seconds since midnight and adjust the ticks accordingly.
The preferred file format is called PlotML, and is described fully in the Plot chapter. It is a textual format in XML, the popular extensible markup language used widely on the internet. An older (and more compact) textual format is also supported. Binary data files are also supported, see 3.2 How do I plot binary data? All three formats are demonstrated in the demos.
If you write Java code, the key method for adding data points is the addPoint() method of the Plot class. The Fourier Series demo uses this method.
You can also plot data dynamically as shown in the live plot demo.
pxgraph
program.
For details on the format see the
javadoc Pxgraph documentation for the PxgraphParser class.
The Java program below shows how to generate a raw binary data file with two data points in it.
cxh@tycho 25% cat BinaryData.java import java.io.*; class BinaryData { public static void main(String args[]) { try { FileOutputStream fileOutput = new FileOutputStream("binary.plt"); DataOutputStream dataOutput = new DataOutputStream(fileOutput); // First pair dataOutput.writeFloat(1); dataOutput.writeFloat(1); // Second pair dataOutput.writeFloat(2); dataOutput.writeFloat(3); dataOutput.close(); fileOutput.close(); } catch (IOException e) { System.out.println("Failed to open a file: " + e); } } } cxh@tycho 26% javac BinaryData.java cxh@tycho 27% setenv CLASSPATH . cxh@tycho 28% java BinaryData cxh@tycho 29% od -c binary.plt 0000000 ? 200 \0 \0 ? 200 \0 \0 @ \0 \0 \0 @ @ \0 \0 0000020 cxh@tycho 30% pxgraph -binary binary.plt
pxgraph
script and the pxgraphargs
applet parameter take the
following arguments:
-binary
- use the endian format of the machine
that the Java virtual machine is running on.
-bigendian
- the file is in big-endian format,
convert it if the Java virtual machine is running on a little-endian machine.
-littleendian
- the file is in little-endian format,
convert it if the Java virtual machine is running on a big-endian machine.
In an applet, you can copy the plot to the clipboard in Encapsulated PostScript (EPS) format by typing Control-C.
You can export the plot to standard out in EPS by typing an E
.
Note that printing is supported from standalone applications (ptplot, pxgraph, and histogram). These applications can also export encapsulated postscript files.
To generate a GIF image, you might try first generating PostScript
by printing to a file or exporting EPS,
and then using pstogif
, which is part of Ghostview, available
at
http://www.cs.wisc.edu/~ghost/
. Below is an example:
pxgraph -print -o /tmp/data.ps demo/data.plt pstogif /tmp/data.psUnder Windows, you can use Print Screen to capture a screen shot, the help system says:
To copy the window or screen contentsYou can paste into Paint, which can be started using Start->Programs->Accessories->Paint From Paint, you can save a gif You can open the gif with Start->Programs->Accessories->Imaging and save a jpg.Note - To make a copy of only the active window, press ALT+PRINT SCREEN.
- To copy the entire screen as it appears on your monitor, press PRINT SCREEN.
To paste the image into a document, click the Edit menu in the document window, and then click Paste.
Under Windows, you may want to try using
Snagit,
which is a commercially available program.
http://ptolemy.eecs.berkeley.edu/java/ptplot/exportPNG-0.0.1.patch.gz
is a gzipped patch to Ptplot 5.2 by Bernard Guillot that "allows Easy Export to PNG. This in turn becomes an easy path to export to GIF and JPG.". Portions of the patch are under the GNU Lesser General Public License 2.1, see
http://www.gnu.org/copyleft/lesser.html
for details. This patch has _not_ been tested by the Ptplot pteam at
UC Berkeley.
To generate gifs, the servlet code at
http://ptolemy.eecs.berkeley.edu/java/ptplot/ptolemy-plot-servlet.tar.gz
might be of use.
This is a gzipped tar file that contains sample code to use Ptplot as a
servlet. The code was written by Alberto Gobbi, and has _not_ been
tested by the Ptplot pteam at UC Berkeley.
pxgraphargs
applet parameter can be used to pass
more than one file to the plotter. The pxgraphargs
parameter
can also pass pxgraph
command line arguments.
For example, the HTML below would plot two datafiles at once. The title
of the plot would be Two datafiles
.
<APPLET name="twofiles" CODE="ptolemy.plot.PlotApplet" Height=400 Width=400 codebase="../../.." archive="ptolemy/plot/plotapplet.jar" alt="If you had a java-enabled browser, you would see an applet here." > <param name="pxgraphargs" value="-t 'Two datafiles' file1.plt file2.plt"> <hr>If your browser recognized the applet tag, you would see an applet here.<hr> </APPLET>An alternative is to use ptplot to merge the two files into one plot, then save as a single file.
LogAxes.htm
for an applet that has two separate plots side by side.
See
TwoPlotExample.java
for a standalone application that has two separate plots side by side.
PlotApplication.java
is a standalone application with a menu interface. It has derived
classes PlotMLApplication,
which adds the ability to read PlotML files, and
EditablePlotMLApplication, which adds the ability to edit the data being plotted.
EditablePlotMLApplication
is started by the $PTII/bin/ptplot
startup script.
You can start up the standalone application by hand with:
java -classpath plotapplication.jar ptolemy.plot.plotml.EditablePlotMLApplication demo/sinusoids.xml
ptolemy/plot/demo/TwoPlotExample.java
is a simple standalone Java application that uses the Plot class.
The comment towards the top of the file contains instructions about
how to compile it.
However, if you are using a recent version of the Java Plug-in, then
you can use the simpler
<applet> . . . </applet>
style.
Note that this style will not work under Netscape 4.7x.
$PTII/ptolemy/plot/demo/MarksSimple.htm
uses this simpler style.
For more information about how to write applets that use
the Java Plug-in, see
http://java.sun.com/products/plugin/versions.html
codebase
parameter controls where
and applet may look for data files. See
http://java.sun.com/docs/books/tutorial/applet/appletsonly/data.html
for details.
For example, to move the
../demo/MarksSimple.html
file out of the Ptplot tree, follow these steps below:
mkdir ~/public_html/ptplot cd ptplot5.2/ptolemy/plot cp plotmlapplet.jar ~/public_html/ptplot cp demo/MarksSimple.htm ~/public_html/ptplot cp demo/plotmlSample.txt ~/public_html/ptplot cp plotml/PlotML_1.dtd ~/public_html/ptplot1) Edit
~/public_html/ptplot/Marks.htm
and change
codebase
from "../../.."
to
"."
archive
from
ptolemy/plot/plotmlapplet.jar
to plotmlapplet.jar
<APPLET code = "ptolemy.plot.plotml.PlotMLApplet" codebase = "." archive = "plotmlapplet.jar" width = "600" height = "400" > <PARAM NAME = "background" VALUE = "#ffffff" > <PARAM NAME = "dataurl" VALUE = "plotmlSample.txt" > No Java Plug-in support for applet, see <a href="http://java.sun.com/products/plugin/"><code>http://java.sun.com/products/plugin/</code></a> </APPLET>
~/public_html/ptplot/plotmlSample.txt
and change the dtd from ../plotml/plotml.dtd
to PlotML_1.dtd
:
2c2 < <!DOCTYPE plot SYSTEM "PlotML_1.dtd"> --- > <!DOCTYPE plot SYSTEM "../plotml/plotml.dtd">
XLog: onor
YLog: onshould appear before any data. Also, the value of the XTicks, YTicks or XRange or YRange directives should be in log units. So,
XTicks: 1K 3will display the string
1Kat the 1000 mark.
You could write code that would do a projection of 3D data onto a 2D space, but Ptplot has no z axis, so that would not be that useful.
You could also modify Ptplot so that it would do a waterfall style
plot, where each successive z value was offsite slightly
Figure 5.4 at
http://ptolemy.eecs.berkeley.edu/ptolemyclassic/almagest/docs/user/html/sdf.doc2.html#5.2.2 Sink stars
has an icon of a waterfall plot, which is described as:
Waterfall Plot a series of traces in the style of a waterfall plot. This is a type of three-dimensional plot used to show the evolution of signals or spectra. Optionally, each plot can be made opaque, so that lines that would appear behind the plot are eliminated.
Last Updated: $Date: 2006/05/11 16:40:11 $