multiplot
Description
multiplot is an interactive plotting utility designed to create multiple plots within a single PostScript output file. It reads data from ASCII files, allowing users to define the plotting area, X and Y axis ranges, and plot several datasets on a single graph.
This tool is useful for comparing different datasets visually in a structured manner, where each dataset might represent a separate measurement or a different processing step of the same data.
Usage
multiplot [-infile <asciiplotfile>] [-outfile <metafile_name>]
Arguments
| Option | Description | |
|---|---|---|
-infile <asciiplotfile> | Specifies the initial input ASCII file containing data to plot. If not provided, it prompts for input. | |
-outfile <metafile_name> | Specifies the output PostScript metafile name. | multiplot.meta |
Interactive Mode
After launching, multiplot will guide the user through a series of prompts:
- Plotting Area Dimensions: Prompts for the maximum dimensions of the plotting area (
dx,dyin cm). - File Selection: Prompts for the ASCII plot file name.
- Plot Geometry: Prompts for X and Y axes lengths (
xlength,ylength) and X and Y offsets (xoffset,yoffset) for the current plot within the overall plotting area. - Number of Plots (
noplots): Reads the number of individual plots (noplots) to be drawn on the current graph from the input file. - X-Axis Bounds: Reads X-axis minimum (
xmin) and maximum (xmax) values from the input file. - Y-Axis Bounds (per plot): For each of the
noplots, it reads Y-axis minimum (ymin[i]) and maximum (ymax[i]) values from the input file. - Number of Data Points: Reads the total number of data points (
nopoints) for each plot from the input file. - Data Reading and Plotting: Reads X values and corresponding Y values for each plot from the input file. It then draws lines connecting valid data points within the specified X and Y bounds.
- Continue Plotting: After plotting one graph, it asks “do you want to plot another graph?”. If the user enters ‘y’ or ‘Y’, it loops back to prompt for another ASCII plot file name and continues.
Input File Format (ASCII)
The input ASCII file for each graph is expected to contain:
dx dy(float, float): Maximum dimensions of the plotting area.noplots(int): Number of individual plots on this graph.xmin xmax(float, float): X-axis bounds.- For each plot
ifrom0tonoplots - 1:ymin[i] ymax[i](float, float): Y-axis bounds for ploti. nopoints(int): Number of data points for all plots.- For each data point
jfrom0tonopoints - 1:xval(float): X-coordinate.- For each plot
ifrom0tonoplots - 1:yval(float): Y-coordinate for ploti.
How It Works
- Initialization: Opens the output PostScript metafile (
synname) and initializesplotlib. - Interactive Graph Loop: Enters a loop (
again:andgoto again;) for plotting multiple graphs. - File Input: Prompts the user for an ASCII plot file and opens it.
- Plot Area Setup: Prompts for and sets the maximum plotting area dimensions (
dx,dy). - Plotting Geometry: Reads
xlength,ylength,xoffset,yoffsetfor the current graph. - Data Range Reading: Reads
noplots,xmin,xmax,ymin[],ymax[], andnopointsfrom the input ASCII plot file. - Data Plotting Loop: Iterates through each data point
jand then through each ploti:- Reads
xvalandyvalfrom the input file. - If
xvalandyvalare within their respective plot bounds andyvalis not0.0, it converts them to device coordinates (xpos,ypos). - It then draws a line segment from the
oldxpos/oldypos(previous data point) to the current point (xpos,ypos).
- Reads
- Continue/Exit: After plotting a graph, it asks the user if they want to plot another.
- Cleanup: Calls
plot_closeto finalize the PostScript output.
Output Files
<outfile_name>: A PostScript metafile (.meta) containing the generated plots.
Dependencies
plotlib.h: Forplotlibfunctions.support.h: For general utility functions.
Notes
multiplot is an interactive tool suitable for visually comparing multiple time-series or profile datasets. The input file format is highly specific, requiring explicit definition of plot geometry and data ranges within the ASCII file itself. The interactive nature allows users to build complex composite plots step-by-step.