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.
This style of copyright is often referred to the community as a "BSD" copyright because it was used for the "Berkeley Standard Distribution" of Unix. It is much more liberal that the commonly used "GPL" or "GNU Public License," which encumbers the software and derivative works with the requirement that they carry the source code and the same copyright agreement. The BSD copyright requires that the software and derivative work carry the identity of the copyright owner, as embodied in the lines:
Copyright (c) 1999-2014 The Regents of the University of California. All rights reserved.
The copyright also requires that copies and derivative works include the disclaimer of liability in BOLD. It specifically does not require that copies of the software or derivative works carry the middle paragraph, so such copies and derivative works need not grant similarly liberal rights to users of the software.
The intent of the BSD copyright is to maximize the potential impact of the software by enabling uses of the software that are inconsistent with disclosing the source code or granting free redistribution rights. For example, a commercial enterprise can extend the software, adding value, and sell the original software embodied with the extensions. Economic principles indicate that granting free redistribution rights may render the enterprise business model untenable, so many business enterprises avoid software with GPL licenses. Economic principles also indicate that, in theory, fair pricing of derivative works must be based on the value of the extensions, the packaging, or the associated services provided by the enterprise. The pricing cannot reflect the value of the free software, since an informed consumer will, in theory, obtain that free software from another source.
Software with a BSD license can also be more easily included in defense or national-security related applications, where free redistribution of source code and licenses may be inconsistent with the mission of the software. Ptolemy II can include other software with copyrights that are different from the BSD copyright. In general, we do not include software with the GNU General Public License (GPL) license, because provisions of the GPL license require that software with which GLP'd code is integrated also be encumbered by the GPL license. In the past, we have made an exception for GPL'd code that is aggregated with Ptolemy II but not directly combined with Ptolemy II. For example cvs2cl.pl was shipped with Ptolemy II. This file is a GPL'd Perl script that access the CVS database and generates a ChangeLog file. This script is not directly called by Ptolemy II, and bwe include it as a ``mere aggregation'' and thus Ptolemy II does not fall under the GPL. Note that we do not include GPL'd Java files that are compiled and then called from Ptolemy II because this would combine Ptolemy II with the GPL'd code and thus encumber Ptolemy II with the GPL.
Another GNU license is the GNU Library General Public License now
known as the GNU Lesser General Public License (LGPL). We try to avoid
packages that have this license, but we on occasion we have included
them with Ptolemy II. The LGPL license is less strict than the GPL -
the LGPL permits linking with other packages without encumbering the
other package. In general, it is best if you avoid GNU code. If you
are considering using code with the GPL or LGPL, we encourage you to
carefully read the license and to also consult the GNU GPL FAQ at
http://www.gnu.org/licenses/gpl-faq.html
.
We also avoid including software with proprietary copyrights that do not permit redistribution of the software.
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,
See https://lists.eecs.berkeley.edu/sympa/subscribe/ptplot-announce.
xgraph
and ptplot.
pxgraph
, an extension to xgraph
from
https://ptolemy.berkeley.edu/other/pxgraph.htm
https://ptolemy.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.
https://ptolemy.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
https://ptolemy.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
https://ptolemy.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
https://ptolemy.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.
https://ptolemy.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
https://ptolemy.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.
For more information about how to write applets that use
the Java Plug-in, see
https://www.java.com/versions.html
codebase
parameter controls where
and applet may look for data files. See
http://download.oracle.com/javase/tutorial/deployment/applet/data.html
for details.
For example, to move the
../demo/Marks.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/Marks.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="https://www.java.com/"><code>https://www.java.com/</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
https://ptolemy.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: 2014-10-23 20:01:43 -0700 (Thu, 23 Oct 2014) $