GRAPHICS_EXAMPLES, MATLAB programs which illustrate how various kinds of data can be displayed and analyzed graphically.
The computer code and data files described and made available on this web page are distributed under the GNU LGPL license.
GRAPHICS_EXAMPLES programs are available in a C version and a C++ version and a FORTRAN90 version and a MATLAB version and a Python version.
DRUG_DOSAGE, a MATLAB program which simulates the variation in the blood levels of a medicinal drug being administered at specific dosages and times over a course of treatment. The level should rise about a given medicinal level for some time, but stay below the toxic level.
GRAPHICS_EXAMPLES_CONVERT, examples which illustrate how various kinds of data can be processed and modified using the ImageMagick program convert() and its related tools.
GRAPHICS_EXAMPLES_GNUPLOT, examples which illustrate how various kinds of data can be displayed and analyzed graphically using the interactive executable graphics program gnuplot().
GRAPHICS_EXAMPLES_GRACE, examples which illustrate how various kinds of data can be displayed and analyzed graphically using the interactive executable graphics program grace().
GRAPHICS_EXAMPLES_PLOTLY, examples which illustrate how various kinds of data can be displayed and analyzed graphically, using the plotly() program from a browser.
HISTOGRAM_DISPLAY, a MATLAB program which makes a bar plot of a set of data stored as columns in a file; the first column is the X values, and all the other columns are Y values to be shown as a stack of bars;
MARIO, a MATLAB program which creates a sort of "needlepoint" image of Mario, as an array of colored squares.
MESH_DISPLAY, a MATLAB program which reads data defining a polygonal mesh and displays it, with optional numbering.
XY_DISPLAY, a MATLAB program which reads XY information defining points in 2D, and displays an image in a MATLAB graphics window;
XYF_DISPLAY, a MATLAB program which reads XYF information defining points and faces in 2D, and displays an image in a MATLAB graphics window.
XYL_DISPLAY, a MATLAB program which reads XYL information defining points and lines in 2D, and displays an image in a MATLAB graphics window.
ALBUM_SALES_BAR lists the year, and total number of music albums (LP's, cassettes, CD's and dowloads) sold each year from 2007 to 2017. This data is plotted as a bar graph.
AUTOMOBILE_SCATTER contains 205 records, with 26 attributes, describing properties of cars available in 1985, taken from the UCI Machine Learning Repository. Some data values are missing, and are indicated by '?'. The data is comma separated, and includes text, integers, and real values. Our interest is to make a scatter plot of certain pairs of real attributes.
BROWNIAN_2D_PLOT simulates a jagged wandering path generated by 1000 steps of Brownian motion. Unlike a typical y=f(x) plot, this data wanders around the page.
BROWNIAN_ANIMATION animates Brownian motion by drawing one more step every 1/4 second of viewing time.
BULGARIA_PLOT takes data about the Bulgarian population over time and makes a plot of (time,population).
CAFFEINE_SCATTER seeks a relationship between the percentage of blindness due to cataracts, and the daily intake of caffeine, in a number of countries. A scatter plot is produced.
CIRCLE_INOUT_SCATTERS depicts 500 pairs of (X,Y) data points in the unit square, 395 of which lie inside the unit circle, and 105 outside. On a single graph, we display a scatter plot of the inside points (blue), the outside points (red), and a line representing the perimeter of the circle, using a hold on/hold off combination to combine the three plots.
CORKSCREW_PLOT3D generates (X,Y,Z) points on a curve, and makes a 3D line plot.
CORVETTE_SCATTER considers the resale price for Corvettes by model year, displaying the results as a scatter plot.
DRUG_DOSAGE_PLOTS depicts measurements over 48 hours of the blood level concentration of a medicinal drug. The drug needs to reach a certain level to have an effect, but must not exceed the toxic level. A graphic is created which shows, on one plot, the concentration over time, the minimal effective level, and the maximum nonlethal leval, using a hold on/hold off combination to combine the plots.
GEYSER_BAR contains the waiting time in minutes between successive eruptions of the Old Faithful geyser. 299 values are recorded. The data ranges from 43 to 108. The program arranges the data into 35 bins of width 2 from 40 to 110, and then uses the MATLAB bar() program to display exactly these bins in a bar chart. The data comes from Martinez and Martinez.
GEYSER_HISTOGRAM contains the waiting time in minutes between successive eruptions of the Old Faithful geyser. 299 values are recorded. The data ranges from 43 to 108. The program allows the MATLAB histogram() program to organize the data. The data comes from Martinez and Martinez.
GEYSER_SCATTER looks for relations between the duration in minutes of the eruption and following pause times for the Old Faithful geyser.
GRID_CONTOUR records, on a 41x41 grid over [-2,2]x[-2,+2], the values z = exp(-(x^2+y^2)) * cos(0.25*x) * sin(y) * cos(2*(x^2+y^2)). MATLAB's contourf() function can then plot the data as a color contour.
GRID_SURFACE records, on a 41x41 grid over [-2,2]x[-2,+2], the values z = exp(-(x^2+y^2)) * cos(0.25*x) * sin(y) * cos(2*(x^2+y^2)). MATLAB's meshgrid() function can then plot the data as a surface.
INSECT_SCATTER3 involves 3 data sets, each containing 10 measurements of 3 quantities for each of 3 species of insect. The quantities are first tarsus width, second tarsus width, and maximum width of the aedeagus. It is of interest to know whether these three measurements are enough to differentiate between members of the three species. A 3D scatter plot is created.
IRIS_SUBPLOTS demonstrates the use of subplots. In this case, there are three varieties of iris, and for each, several specimens have been collected and measurements recorded for sepal length, sepal width, petal length and petal width. It is desired to create a 4x4 array of plots of each possible pair of variables. Moreover, data is to be color-coded by iris variety.
LEAST_SQUARES_PLOTS compares 15 pairs of (x,y) data, the least squares line that approximates their behavior, and a quadratic curve that is much closer to the data.
LISSAJOUS_PLOT records 1000 points on a Lissajous curve defined by x=sin(3*t+pi/2), y=sin(4t). The curve is to be plotted and every tenth point marked.
LYNX_PLOT makes a line plot of the yearly lynx harvest from 1821 to 1934. Data points are marked by circles.
MARIO_FILL makes a simple image of Mario, using MATLAB's fill() command to create a grid of colored squares.
NILE_HISTOGRAM makes a histogram of the yearly measurement of the height of the Nile at maximum flood.
NILE_PLOT makes a line plot of the yearly measurement of the height of the Nile at maximum flood.
NINETY_HISTOGRAM considers 90 numeric values. We create a histogram, to see how the data spreads out across its range. We spot outliers as histogram bins of low occupancy that are far from the rest of the data.
ORBITAL_CONTOUR records, on a 101x101 grid over [0,4*pi]x[0,4*pi], the minimum distance between two planets given a pair of orbital angles. MATLAB's contourf() functiom makes a color contour plot of this data.
PREDATOR_PLOT3D models the change in population over time of foxes and rabbit, and then uses MATLAB's plot3 command to create a 3D line plot of prey, predator, and time values.
PRESIDENT_HEIGHTS_BAR plots the heights of US presidents in inches, as a bar plot. The data file is in CSV format, so the first row and the first column need to be skipped.
PRESIDENT_HEIGHTS_HISTOGRAM plots the heights of US presidents in inches, as a histogram. The data file is in CSV format, so the first row and the first column need to be skipped.
PRICE_PLOTS reads a table of average monthly prices for 11 consumer products, between February 2008 and February 2018, as compiled by the Bureau of Labor Statistics, and plots together the prices of three of the items.
RANDOM_SCATTER generates 500 pairs of (X,Y) data, which lie in the unit square, and tend to cluster around (0.5,0.5).
SNOWFALL_HISTOGRAM makes a histogram of the yearly snowfalls totals.
SNOWFALL_PLOT makes a line plot of the snowfall at Michigan Tech from 1890 to 2017.
SNOWFALL_SMOOTHED_PLOT uses MATLAB's conv() command to compute a 10 year moving average of the snowfall at Michigan Tech from 1890 to 2017, and plots the smoothed data.
TRACK_BAR considers an eye-tracking experiment in which the eye was focused on different regions for different durations. Each region has a text label. A bar graph is desired, in which the bar for each duration is given the appropriate label.
TRACKS_BAR considers an eye-tracking experiment in which the eye was focused on different regions for different durations. Each region has a text label. The data from several experiments is to be combined and averaged. A bar graph is desired, in which the bar for each duration is given the appropriate label.
USTEMPS_SCATTER shows locations in the US where the January temperature was recorded.
You can go up one level to the MATLAB source codes.