Ptplot Frequently Asked Questions

Below are some answers to frequently asked questions about ptplot. This page contains links to documents about Ptplot internals and infrastructure.

Contents

  • 1. General
  • 1.1 What Is Ptplot?
  • 1.2 How do I pronounce 'ptplot'?
  • 1.3 What is the copyright?
  • 1.4 How do I contact the authors?
  • 1.5 Is there a mailing list?
  • 1.6 What is the relationship between xgraph and ptplot?
  • 2. Installation questions
  • 2.1 How do I download ptplot?
  • 2.2 What platforms does ptplot run under?
  • 2.3 What do I need to Install Ptplot?
  • 2.4 Troubleshooting
  • 2.5 Is there a bug list?
  • 3. How do I . . .
  • 3.1 Plot my own data?
  • 3.2 How do I plot binary data?
  • 3.3 How do I handle endian issues in binary data?
  • 3.4 How do I print a plot from a Plot applet?
  • 3.5 How do I plot two datafiles in an applet?
  • 3.6 How do I have two separate plots?
  • 3.7 How do I create a simple standalone Plot application?

  • 1. General

    1.1 What Is Ptplot?
    Ptplot is a Java 2-D graphing component. Ptplot can be used in applets and applications. The top-level Ptplot page describes Ptplot further.
    1.2 How do I pronounce 'ptplot'?
    pee-tee-plot. Unlike with Ptolemy, the initial p in the pt is pronounced.
    1.3 What is the copyright?
    Ptplot is released under the fairly liberal UC Berkeley copyright. Most files have the copyright at the top, for example, see Plot.java
    1.4 How do I contact the authors?
    The primary author of Ptplot is Professor Edward A. Lee. Christopher Hylands is a coauthor. William Wu and Lukito Muliadi contributed code. You can contact the authors via ptplot@ptolemy.eecs.berkeley.edu
    1.5 Is there a mailing list?
    We maintain the 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@ptolemy.eecs.berkeley.edu with the word subscribe in the body, not the header.
    1.6 What is the relationship between xgraph and ptplot?
    The introduction contains a description of the relationship between xgraph and ptplot.
    Note that you can download sources and binaries for pxgraph, an extension to xgraph from http://ptolemy.eecs.berkeley.edu/other/pxgraph.htm
    Note that if you type a x while the mouse is over the Java pxgraph application window, and the X11 version of pxgraph is installed as pxgraph.x11, then pxgraph.x11 will be started up with the same command line arguments that you called the Java pxgraph with. This is one way of using the Java version most of the time, but still having access to the MIF output facilities in the X11 version.

    2. Installation questions

    2.1 How do I download Ptplot?
    http://ptolemy.eecs.berkeley.edu/java/ptplot.htm has links to the tar and zip files.
    2.2 What platforms does Ptplot run under?
    Ptplot was develop under JDK1.2.1. Most of the simple applets should work under browsers that support JDK1.1 (Netscape 4.61 and IE 5).

    The Java Plug-in allows JDK1.1 browsers under Windows to run JDK1.2 applets. As of the 3.1 release of Ptplot, none of the plugins we are shipping require the JDK1.2 Plug-in

    Older browsers may not have support for JDK1.1, you may need to upgrade your browser.

    Note that Ptplot3.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 ptplot1.3 and earlier supported JDK1.0.2, you can find those releases in http://ptolemy.eecs.berkeley.edu/java/old.

    2.3 What do I need to Install Ptplot?
    To use Ptplot, you will need the Java Development kit (JDK), which can be downloaded from http://www.javasoft.com.

    See the Installing Ptplot page for more information

    You can also run Ptplot as an applet in your local browser.

    2.4 Troubleshooting
    The Ptplot Troubleshooting guide has a few hints.

    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@ptolemy.eecs.berkeley.edu. Your mail should include:

    1. What version of Ptplot you are running.
    2. What platform you are running under (Solaris, Windows etc.)
    3. Exactly how to reproduce the bug.
    2.5 Is there a bug list?
  • Most of the known bugs and limitations are listed in the javadoc Plot documentation
  • The Todo list is at the top of the Plot.java file.

  • 3. How do I . . .

    3.1 How do I plot my own data?
    There are several ways to plot data using ptplot. You can read data from a file on the local filesystem, or from a file on the internet via a URL. You can sketch your own data and then save the file. Or you can create Java applications or applets that directly call methods of the Plot classes to create the plot.

    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.

    3.2 How do I plot binary data?
    Ptplot can plot binary datafiles in an older file format originally created by Joe Buck for the X11 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
    
    
    3.3 How do I handle endian issues in binary data?
    Traditional C/C++ programs encode binary data in different formats on different platforms.
  • Big-endian - SPARCs and the network in general use this format.
  • Little-endian - Intel x86 chips use this format.
  • Problems can occur when you try to read a binary format file on a machine other than the machine it was created on. Java always reads binary data in big-endian format, so the 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.
  • See the Endian Examples for example that use the above flags. The Java Programmer's FAQ has more information about endian issues.
    3.3 How do I print a plot from a Plot applet?
    Unfortunately, most browsers cannot print applets. There are work arounds, but in general, it is hard, and involves security violations. http://www.best.com/~pvdl/javafaq.htm says:
    4.1.11 How do I print a page with an applet?

    A. Browsers are starting to introduce support for this. Until they all have it, your best bet is to print a screendump. Using the browser to print the page may leave a blank where the applet is. Putting print support in the applet will print the applet only, not the rest of the browser page.

    Sun's HotJava browser can be used to print pages that contain applets. However, it seems like the Windows version sometimes crashes when printing. The Solaris version of HotJava1.1 works fine.

    For more information about printing, join the JavaSoft Developer Connection (it is free) and search for printing.

    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.ps
    
    3.5 How do I plot two datafiles in an applet?
    In applications (ptplot, pxgraph, and histogram), this is easy: just specify the two files on the command line. In applets, only PxgraphApplet supports this. The 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.
    3.6 How do I have two separate plots?
    See 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.

    3.7 How do I create a simple standalone Plot application?
    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 ptplot startup script.

    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.

    Last Updated: $Date: 1999/08/20 15:44:29 $