Introduction to Xplot
This page is an introduction to using Xplot on FreeBSD and on creating
Xplot files using the xplotLib routines.
Using Xplot
path (on FreeBSD machines): /usr/dirt/bin/xplot-dirt
Xplot reads from a text file (for example, xplotFile.xpl) to generate
its plots. These files can be created using the xplotLib routines
that are described below.
running Xplot: xplot xplotFile.xpl
Xplot is particulary useful when plotting large amounts of data.
The Xplot user interface allows zooming into specific regions on the graph.
Postscript files (both full-page and smaller) can also be created.
Xplot User Interface
Version 0.90 Command Line Options
Mark's Wonderful Additions to Xplot
General Format of Xplot Files
All Xplot files must begin with the following header: (After the
header, everything in the xplot file is a plot command.)
[x-axis type] [y-axis type]
title
[Enter title here]
xlabel
[Enter x-axis label here]
ylabel
[Enter y-axis label here]
Plot command format: [shape] [x-coordinate] [y-coordinate] [color]
Text plot command format:
[text cmd] [x-coordinate] [y-coordinate]
[text to print]
Axis types: timeval, double, signed, unsigned (don't use unsigned...)
Shapes: x, dot (or .), plus (or +), box, diamond, utick, ltick,
dtick, rtick, vtick, uarrow, darrow, larrow, rarrow, line, dline (dotted line),
invisible (plots an invisible point, so you can control axis range)
Text cmds: ctext (center on point), rtext (to the right of point),
ltext (to the left of point), atext (above the point), btext (below the point)
Colors: red, blue, yellow, green, white, magenta, orange, purple,
chartreuse1, yellow1, khaki1, sienna1, wheat1, tan, salmon, hotpink,
LightBlue1, LightGreen, red4 OR {0..16}
Using xplotLib++ (and xplotLib)
xplotLib++ path: ~clark/dirt/include/xplotLib++.{c,h}
(C++ style functions, compile code with g++)
xplotLib path ~clark/dirt/include/xplotLib.{c,h}
To use xplotLib++ routines: include and compile xplotLib++.c
in your makefile OR use an already compiled xplotLib++.o file found in
~clark/dirt/include/FreeBSD
(This will be changed later to make using
xplotLib++ easier.)
xplotLib++ routines:
xplotLib routines:
void createHeader (FILE* fp, char* xtype, char* ytype, char*
title, char* xlabel, char* ylabel, char* dumpFilename, char* xplotFilename);
void plotter_time_un_line
(FILE*, struct timeval x1, unsigned y1, struct timeval x2, unsigned y2,
char* color);
** Plots a line with unsigned
values on the y-axis vs timeval values on the x-axis
void plotter_time_sign_line (FILE*, struct
timeval x1, int y1, struct timeval x2, int y2, char* color);
** Plots a line with signed values on the y-axis vs timeval
values on the x-axis
void plotter_time_double_line (FILE*, struct
timeval x1, double y1, struct timeval x2, double y2, char* color);
** Plots a line with double values on the y-axis vs timeval
values on the x-axis
void plotter_un_un_line (FILE*, unsigned x1,
unsigned y1, unsigned x2, unsigned y2, char* color);
** Plots a line with unsigned
values on the y-axis vs unsigned values on the x-axis
void plotter_time_un_dot (FILE*, struct timeval
x, unsigned y, char* color);
** Plots a dot with unsigned
values on the y-axis vs timeval values on the x-axis
void plotter_un_un_dot (FILE*, unsigned x,
unsigned y, char* color);
** Plots a dot with unsigned
values on the y-axis vs unsigned values on the x-axis
void plotter_time_sign_dot (FILE*, struct
timeval x, int y, char* color);
** Plots a dot with signed
values on the y-axis vs timeval values on the x-axis
void plotter_time_double_dot (FILE*, struct
timeval x, double y, char* color);
** Plots a dot with double
values on the y-axis vs timeval values on the x-axis
If there are any other routines that you think would be useful, please
let me know.
xplotLib++ Example
#include "xplotLib++.h"
void main (int argc, char* argv[])
{
struct timeval recvTime, lastPlotTime;
double intervalPercent, lastIntPercent;
FILE* dumpFP, *outFP;
char dump[255]="", outfile[255]="";
...
createHeader (outFP, "timeval", "double",
"loss percentage vs. receive time", "receive time",
"loss percentage", dump, outfile);
...
plotDot (outFP, recvTime, intervalPercent, "red");
plotLine (outFP, lastPlotTime, lastIntPercent, recvTime, intervalPercent,
"yellow");
}
Other examples (that were included with Xplot) can be found at
/usr/src/xplot-0.90/demo.* on the FreeBSD machines.
Help! My Time-Sequence Number Graphs Don't Plot!
New tcptrace (with double default for tsg instead of
unsigned): ~clark/bin/tcptrace
(source is in ~clark/src/tcptrace/)
According to the xplot README, "xplot does not behave well when you wrap
around the end of a coordinate space. This is particularly likely if the
unsigned coordinate type is used and you attempt to scroll or zoom to
values below zero. Because of this, the unsigned coordinate type is not
recommended. However, unsigned is the only reasonable choice for TCP
sequence numbers. A 64-bit signed integer coordinate type should be added
to xplot someday. For typical applications, double should be used for both
coordinate types."
If you used tcptrace to generate time-sequence-number plots and
your plots don't show up properly, it is probably because the sequence
numbers are greater than what can be represented in 31 bits.
Change the first line of your files from:
timeval unsigned
to
timeval double
This should solve the problem.
Other
DiRT documents
Author: Michele Clark
Last updated: October 10, 1998