Ptplot FAQ

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 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 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 ftp://ptolemy.eecs.berkeley.edu/pub/misc/pxgraph/index.html
    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.html has links to the tar and zip files.
    2.2 What platforms does Ptplot run under?
    Ptplot was develop under JDK1.1.4. The only part of Ptplot that requires JDK1.1 is the printing method in the Pxgraph class and the Message class, which is used by the Pxgraph class for the 'About' window. The rest of the code should compile under JDK1.0.2. The code contains comments that indicate the various 1.0.2/1.1 compatibility issues.
    Everything else compiles under JDK1.0.2. The ptplot.zip file we supply was built with JDK1.0.2. We chose to do this so that we could support Netscape3.x. The next release might only support JDK1.1 and later.
    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. The Pxgraph documentation contains further installation instructions.

    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 cxh@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.

    One is to create a datafile that consists of datasets and x,y pairs See: demo/bargraph.plt

    Binary data files are also supported, see 3.2 How do I plot binary data?

    Another ways it to call plot().addPoint. The Fourier Series demo uses this method. The PlotFourierSeries class at demo/PlotFourierSeries.java is what actually does the plotting.

    You can also plot data dynamically by creating a class that has a addPoints() method which gets called by the PlotLive class. The demo/Live.html demo illustrates live plotting. The PlotLiveDemo class at demo/PlotLiveDemo.java is what actually does the plotting.

    3.2 How do I plot binary data?
    Ptplot can plot binary datafiles. Ptplot 1.1 and earlier can plot data in the format that was originally created by Joe Buck for the X11 pxgraph program. For details on the format. Ptplot 1.2 and later can also plot data that consists of raw 4 byte floats. For more information, see the description of the -binary option in Pxgraph.java. You might find the javadoc Pxgraph documentation easier to read.
    3.3 How do I handle endian issues in binary data?
    Binary data is encoded in different ways 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. pxgraph 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.html 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 Pxgraph applications in the Pxgraph class. Note that printing in the Pxgraph class requires JDK1.1 and later.

    The ptplot2mif.tcl Tcl script can be used to convert the PostScript output of the Pxgraph application to Framemaker MIF format. This script requires Tcl and probably works only with the Sun Solaris JDK. To create a MIF file, use the pxgraph script to display your data, print to file, then run ptplot2mif.tcl on your file

    You might want to use the -print option to bring up the print window immediately and the -o option to specify an output file for the PostScript. Below is an example:

    pxgraph -print -o /tmp/data.ps demo/data.plt
    ptplot2mif.tcl /tmp/data.ps > /tmp/data.mif
    
    Note that you can also bring up the X11 pxgraph version from after starting the Java version by typing an x. For more information, see 1.6 What is the relationship between xgraph and ptplot?.

    To generate a GIF image, you might try first generating PostScript 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?
    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="ptplot.PlotApplet" Height=400 Width=400
        codebase="../.."
        archive="ptplot/ptplot.zip"
        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>
    
    3.6 How do I create a simple standalone Plot application?
    Pxgraph.java is a standalone application that uses the Plot class. Pxgraph.java is fairly large, but most of the code is for argument parsing and backward compatibility with an older program. Most of the real work is done in the Pxgraph constructor and in main().

    PlotApplication.java is a simple standalone Java application that uses the Plot class.

    Here's how to compile and run it

    1. Change to the ptplot directory:
      cd ptplot
      
    2. Copy the Java code to the ptplot directory:
      cp doc/internals/PlotApplication.java .
      
    3. Set your CLASSPATH to point to the directory above the ptplot directory:
      setenv CLASSPATH ..
      
      Note that you might want to use an absolute path for your CLASSPATH if you plan on using PlotApplication from any directory. Note further that setting your CLASSPATH in your environment is bound to cause problems with other applications, such as Netscape. In general it is best to have a shell script that sets the CLASSPATH appropriately for each Java application.

    4. Compile the Java class:
      javac PlotApplication.java
      
    5. Run the class with a sample datafile:
      java ptplot.PlotApplication demo/data.plt
      


    Ptplot infrastructure


    Copyright © 1997-1998, The Regents of the University of California. All rights reserved.
    Last updated: 06/07/98, comments to: cxh@eecs.berkeley.edu