ball_and_stick_display, a MATLAB code which makes a 3D "ball and stick" plot.

MATLAB has many procedures for displaying numeric data in 3D using contours, vector plots, surfaces and so on. However, sometimes an illustrator needs to construct a simple 3D image of points and lines. Since the thing has to show up as an illustration or a slide, the points are exaggerated to balls, and the lines to sticks.

MATLAB's plot3 command can create both kinds of objects, but it helps to know how to specify the desired object properties for color and size. The MATLAB help system is not very helpful when trying to find out what properties you can specify and what values they can have.

So this program may be a helpful example of how a 3D object can be created with knobby balls and colored sticks.

The particular object created here is intended to illustrate the Lax-Wendroff scheme for approximating the solution of a hyperbolic partial differential equation. The blue spheres represent points at which data is known. The green spheres represent points at which fluxes are estimated by computing differences between neighboring values. The red sphere is the locationi of the updated solution value.


The computer code and data files made available on this web page are distributed under the MIT license


BALL_AND_STICK_DISPLAY is available in a MATLAB version.

Related Data and Programs:


bezier_surface_display, a MATLAB code which displays a Bezier surface;

circle_grid_display, a MATLAB code which reads a matrix of integers, and draws a corresponding grid of circles filled with color.

grid_display, a MATLAB code which can display a 2D or 3D grid or sparse grid.

obj_display, a MATLAB code which reads an OBJ 3D graphics file and displays it on the screen.

polygonal_surface_display, a MATLAB code which displays a surface in 3D described as a set of polygons;

quad_surface_display, a MATLAB code which plots piecewise bilinear data associated with a QUAD_SURFACE, that is, a 3D surface defined by a quadrilateral mesh;

stla_display, a MATLAB code which reads an ASCII STL file and displays it on the screen.

tet_mesh_display, a MATLAB code which reads in the node and tetra files defining a tet mesh and displays a wireframe image.

tri_surface_display, a MATLAB code which displays the 3D graphics information in a TRI_SURFACE file;

Source Code:

Last modified on 23 December 2018