<<<<<<<<<<<<<<<<

xplot(x) Xlib xplot(x)

NAME

xplot - a 2D plotting class for X windows

DESCRIPTION

The Xplot class is a 2D plotter using X drawable objects for its display. It takes data from plot_data instances and displays a graph of the data. The data can be plotted as lines, points or bars. Titles, tick marks and a grid can also be displayed.

SUPERCLASS

object

INSTANCE VARIABLES

window The name of the xdrawable object to draw in.

font The name of the xfont object to use for titles and labels.

border The size in pixels of the top, bottom, left and right borders. This defines the drawing area inside the window. Titles and labels are drawn in the border area.

x_title The title for the x-axis.

y_title The title for the y-axis.

title The title for the graph.

tick_res The number of tick marks to draw on the x and y axes. The default is (0,0) - no tick marks.

grid_res The number of boxes defined by the grid. The default of (0,0) disables the grid. A value of (2,2) would divide the plotting area into quadrants. A (1,1) grid resoltion puts a border around the drawing area.

global_x_range The min and max x values for the plot to span. These are automatically set to the min and max x data values when autoscale is on.

global_y_range The min and max y values for the plot to span. These are automatically set to the min and max y data values when autoscale is on.

data_sets The names of the plot_data objects to be drawn.

MESSAGES

window[=?] Set/get the name of the window to draw in.

font[=?] Set/get the name of the font. The default is "fixed_font".

x_title[=?] Set/get the x-axis title.

y_title[=?] Set/get the y-axis title.

title[=?] Set/get the plot title.

tick_res[=?] Set/get the tick mark resolution.

grid_res[=?] Set/get the grid resolution.

global_x_range[=?] Set/get the global x range.

global_y_range[=?] Set/get the global y range.

data_sets[=+-?] Set/add/remove/get the names of the plot_data objects to be drawn.

auto_scale! Perform autoscaling on the data. Automatically sets the border (if it is too small) and the global x and y ranges according to the specified data sets.

draw_axes! Draws the plot axes in the window.

draw_titles! Draws the plot title and axes titles in the window.

draw_tick! Draws the tick marks in the window.

draw_grid! Draws the grid in the window.

draw_set: set_name Plots the data in set_name in the window.

draw! Draws the entire plot and flushes the window. Sends a map! and clear! to the window, and sends draw_axes!, draw_titles!, draw_tick!, and draw_grid! to itself for each of those components that is enabled. Then it sends draw_set: to all of its data_sets. It finishes by sending a flush! to the xdisplay class.

ticks_on!/ticks_off! Enables or disables the drawing of tick marks in the plot. (Default is on.)

grid_on!/grid_off! Enables or disables the drawing of a grid in the plot. (Default is on.)

axes_on!/axes_off! Enables or disables the drawing of axes in the plot. (Default is on.)

titles_on!/titles_off! Enables or disables the drawing of titles in the plot. (Default is on.)

points! Sets the plot type to points. A pixel is drawn for each data point.

lines! Sets the plot type to lines. Segments are drawn between consecutive data points.

bars! Sets the plot type to bars. A vertical line with a horizontal cap is drawn for each data point.

auto_scale_on! Turns autoscaling on.

auto_scale_off! Turns autoscaling off.

DELEGATED MESSAGES

The following messages are accepted by the xplot class and delegated to its window instance variable.

height[=+?] Set/add/get the height of the window.

width[=+?] Set/add/get the width of the window.

x[=+?] Set/add/get the x position of the window.

y[=+?] Set/add/get the y position of the window.

clear! Clear the window.

lower! Push the window to the bottom of the stack of windows on the screen.

raise! Pop the window to the top of the stack of windows on the screen.

map! Map the created window onto the screen - this may be intercepted by the window manager to allow interactive sizing and placement of the window.

unmap! Unmap the window from the screen.

EXAMPLES

The following LYMB script shows in detail how to draw a plot. First, two X color cells are created and set to white and black. Then an Xgc is created and its foreground and background colors are set. An X window is also created and its gc and background_pixel are set. Then data for the plot is placed into a plot_data object. Finally, the xplot object is created and the plot is drawn. This example requires a lot of supporting objects to get an xplot drawn and is typical of the complexity of X.

xshared_cell new: white rgb: (1,1,1) ;

xshared_cell new: black rgb: (0,0,0) ;

xgc new: def_gc

background=[white pixel?]

foreground=[black pixel?]

create!

change! ;

xwindow new: xw width=400 height=400 gc=def_gc create! background_pixel: [white pixel?] ;

/* * Note: x_data defaults to (0, 1, ..., n) */ plot_data new: data1

y_data=( 0,40,10,60,10,80,50,100,-10,30) ;

xplot new: pl window=xw lines! grid_res=(2,2) tick_res=(10,10) title="MAIN TITLE" x_title="X AXIS" y_title="Y AXIS" data_sets=(data1) ;

pl draw!;

SEE ALSO

xshared_cell, xprivate_cell, xgc, xwindow, xdrawable, xfont, plot_data

BUGS

If the global_x_range or global_y_range is less than that of the data set, the plot will not be clipped and may run over into the border of the plot.


Last Updated On: Fri Mar 10 15:38:48 1995

Please send comments and suggestions to

its-documentation@rpi.edu

Keyword Search of RPInfo Consulting Pages and NewsCache