Los Alamos National Laboratory

D  Decision Applications


  • Group Leader
    Kristin Omberg
  • Deputy Group Leader
    David Cremer
  • Office Administrator
    Lorraine Johnson
  • Group Office Location
    TA-52, Bldg. 115
    MS K551

Plot Library

The Los Alamos National Laboratory (LANL) Plot Library can be used to generate two dimensional line plots, two dimensional contour plots, and two dimensional line plots with one of the axes as a date axis.

To generate a line plot requires creating the data, and then making calls to the library.

import d3.plotting.XYPlotFrame;
double [] xaxis = {0,5};
double [] yaxis = {0,5};
double [] x2axis = {1,4};
double [] y2axis = {4,1};

XYPlotFrame plot = new XYPlotFrame();
plot.addLine(“First Line in Example “, xaxis, yaxis);
plot.addLine(“Second Line in Example “, x2axis, y2axis);
plot.showPlot(“Graph Title”, “Plot Title “, “X Axis Label (meters)”, “Y Axis Label (feet)”,
XYPlotFrame.LINEAR, XYPlotFrame.LINEAR);

This code generates the plot below:

line plot graph

The graph title is the title of the JFrame that holds the plot. The JFrame is not shown in the figure above. The axes in the showPlot call may be either XYPlotFrame.LINEAR, or XYPlotFrame.LOG.

A date plot works the same as a line plot, except that the date axis values for each line must be a double array that are the milli-seconds after the epoch. Example calls for a plot with the x axis as a date axis are shown below:

double [] xaxis = {6.4E8, 3.232E9};
double [] yaxis = {0,5};
double [] x2axis = {6.9E8, 2.7E9};
double [] y2axis = {5,0};
DateXYPlotFrame plot = new DateXYPlotFrame();
plot.addLine("First Line in Example ", xaxis, yaxis);
plot.addLine("Second Line in Example ", x2axis, y2axis);
plot.showPlot("Graph Title", "Plot Title ", "The date", "Y Axis
Label (feet)", DateXYPlotFrame.DATE, DateXYPlotFrame.LINEAR);
line plot graph

The plot axes may be of type DateXYPlotFrame.DATE, DateXYPlotFrame.LINEAR, or DateXYPlotFrame.LOG,

Similarly, to generate a contour plot:

double [] range = {…evenly spaced values for the x axis…};
double [] depth = {…evenly spaced values for the y axis…};
double [] stress = {…z value for each x and y…};
ContourPlotFrame plot = new ContourPlotFrame(); plot.addXYZDataSet(range, depth, stress, xBlockSize, yBlockSize); plot.showPlot("Contour Plot Example", "Stress Contours", "Range (m)", "Depth (m)",
"Stress (\u03C3) in kbar", 0, 5);

These calls can be used to generate the contour plot below, when the appropriate data is used for the range, depth, and stress. The gray area has stress values greater than the maximum value in the legend bar. The values for the x axis must be evenly spaced. For instance, there must be an x value at every 20 meters. Similarly, the y axis values must be evenly spaced, but the spacing may be different than for the x axis. The xBlockSize variable is the spacing between the x values, and the yBlockSize is the spacing between the y values.

contour plot graph

When a plot is shown, the JFrame holding the plot has menus for saving the plot, and adjusting the plot display. The menus' selections are described in the Help menu, and in the user guide included with the plot library. To use the plot library, unzip the download and include the LANLPlot.jar file in your class path. Examine the source code to see what methods are available in the XYPlotFrame, DateXYPlotFrame, and ContourPlotFrame classes. There is no developer guide, so you must use the code comments and the source code to understand the settings that are available.

download button (LANL Plot Library.zip)

Top of page

Operated by Los Alamos National Security, LLC for the U.S. Department of Energy's NNSA
Inside | © Copyright 2014 Los Alamos National Security, LLC All rights reserved | Disclaimer/Privacy | Web Contact