# GRAPHICS_EXAMPLES Sample Data for Graphics Demonstrations

GRAPHICS_EXAMPLES, MATLAB programs which illustrate how various kinds of data can be displayed and analyzed graphically.

Some common plot types include:

• plot, a display of a single curve defined by a sequence of functional pairs (x,y(x)), or a function y=f(x) sampled over an interval, or a sequence of related pairs (x,y).
• plots, several curves on a single display.
• plot3d, a 3D display of a single curve defined by a sequence of triples (x(i),y(i),z(i)), or a parametric function (x(t),y(t),z(t)) sampled over an interval.
• scatter, a display of unconnected pairs (x,y), whose positions are indicated by markers.
• scatters, a scatter plot involving several distinct sets of (x,y) pairs are displayed, distinguished by markers of different size, shape or color.
• scatter3d, a 3D display of unconnected triples (x,y,z), whose positions are indicated by markers.
• bar, a display of values y(1:n) in which every value y(i) is represented by a bar of that height.
• histogram, a display of values x in which the x range is divided into intervals, and the value y(i) represents the number of x values in the i-th interval, and a bar plot of intervals versus count is displayed.
• fill, a shape composed of polygons, each of which is filled with a particular color.
• contour, a display of values z(x,y) in which the values of z are suggested by contour lines of selected values.
• color contour, a display of values z(x,y) in which the values of z are suggested by colored areas representing selected values.
• surface, a 3D display of values z(x,y), represented as a surface.
• subplots, a display involving two or more separate plots, shown as a single figure.
• tree, a display of a branching process such as a genealogy or decision tree.
• graph, nodes connected by two-way edges;
• digraph, nodes connected by one-way edges;

### Languages:

GRAPHICS_EXAMPLES programs are available in a C version and a C++ version and a dataset version and a FORTRAN90 version and a MATLAB version and an Octave version and a Python version.

### Related Data and Programs:

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_PLOTLY1, examples which illustrate how various kinds of data can be displayed and analyzed graphically, using version 1 of the plotly() program from a browser.

### Reference:

1. Philipp Janert,
Gnuplot in Action: Understanding Data with Graphs,
Manning, 2010,
ISBN13: 978-1-933988-39-8,
LC: QA276.4.J37.
2. Wendy Martinez, Angel Martinez,
Computational Statistics Handbook with MATLAB,
Chapman and Hall / CRC, 2002,
ISBN: 1-58488-229-8,
LC: QA276.4.M272.
3. Helmut Michels,
The Data Plotting Software DISLIN - version 10.4,
Shaker Media GmbH, January 2010,
ISBN13: 978-3-86858-517-9.

### Examples and Tests:

ALBUM_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. MATLAB graphics commands are used.

AUTOMOBILE_SCATTER contains prices and weights of cars available in 1985. A scatter plot is to be made. MATLAB graphics commands are used.

BASKETBALL_BAR displays the sponsorship dollars for each of 30 basketball players, against their names. A horizontal bar graph is used, which makes it easier to display the name next to the bar. MATLAB's readtable() command is needed in order to handle the data file, which contains a mixture of text and numeric data. MATLAB graphics commands are used.

BROWNIAN_2D_PLOT plots data representing 1000 steps of Brownian motion in two dimensions. Unlike a typical y=f(x) plot, this data wanders around the page. MATLAB graphics commands are used.

BROWNIAN_ANIMATION animates Brownian motion by drawing one more step every 1/4 second of viewing time. MATLAB graphics commands are used.

BULGARIA_PLOT takes data about the Bulgarian population over time and makes a plot of (time,population). MATLAB graphics commands are used.

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. MATLAB graphics commands are used.

CIRCLE_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 scatter plots of the inside points (blue), the outside points (red), and a line representing the perimeter of the circle. MATLAB graphics commands are used.

CORKSCREW_PLOT3D generates (X,Y,Z) points on a curve, and makes a 3D line plot. MATLAB graphics commands are used.

CORVETTE_SCATTER considers the resale price for Corvettes by model year, displaying the results as a scatter plot. MATLAB graphics commands are used.

DECISION_TREE uses MATLAB's treeplot() command to display a decision tree for the iris classification process.

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. MATLAB graphics commands are used.

GENEALOGY_TREE uses MATLAB's treeplot() command to create a tree diagram of a genealogy.

GEYSER_BAR works with measurements of the waiting time in minutes between successive eruptions of the Old Faithful geyser. The data has been grouped into bins. The bin counts are displayed as a bar chart. MATLAB graphics commands are used.

GEYSER_HISTOGRAM contains the waiting time in minutes between successive eruptions of the Old Faithful geyser. MATLAB graphics commands are used.

GEYSER_SCATTER looks for relations between the duration in minutes of the eruption and following waiting times for the Old Faithful geyser. MATLAB graphics commands are used.

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)). A color contour plot is created. MATLAB graphics commands are used.

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)). The data is plotted as a surface. MATLAB graphics commands are used.

INSECT_SCATTER3D 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. MATLAB graphics commands are used.

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. MATLAB graphics commands are used.

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. MATLAB graphics commands are used.

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. MATLAB graphics commands are used.

LYNX_PLOT makes a line plot of the yearly lynx harvest from 1821 to 1934. Data points are marked by circles. MATLAB graphics commands are used.

MARIO_FILL makes a simple image of Mario, by constructing a grid of squares filled with color. MATLAB graphics commands are used.

MEXICAN_HAT_SURFACE plots the function z=sin(r)/r as a 3d surface. MATLAB graphics commands are used.

NETWORK_GRAPH describes a graph as a set of edges, defined by pairs of nodes. MATLAB graphics commands are used.

NILE_HISTOGRAM makes a histogram of the yearly measurement of the height of the Nile at maximum flood. By lumping the data into bins, it is easier to see the range of flood heights, and the probability of various values in the range. MATLAB graphics commands are used.

NILE_PLOT makes a line plot of the yearly measurement of the height of the Nile at maximum flood. MATLAB graphics commands are used.

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. MATLAB graphics commands are used.

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. The data is displayed as a color contour plot. MATLAB graphics commands are used.

PREDATOR_PLOT3D models the change in population over time of foxes and rabbit. A 3D line plot of prey, predator, and time values is made. MATLAB graphics commands are used.

PRESIDENT_HEIGHTS_BAR plots the heights of US presidents in inches, as a bar plot. MATLAB graphics commands are used.

PRESIDENT_HEIGHTS_HISTOGRAM plots the heights of US presidents in inches, as a histogram. By grouping the data by height, we lose the ability to identify specific cases, but we are better able to see the range of heights, and to judge the frequency of various heights. MATLAB graphics commands are used.

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. MATLAB graphics commands are used.

RANDOM_SCATTER generates 500 pairs of (X,Y) data, which lie in the unit square, and tend to cluster around (0.5,0.5). MATLAB graphics commands are used.

SCHOOLYEAR_BAR displays the variation in the length of the school year across various countries. A horizontal bar graph is used, which makes it easier to display the country name next to the bar. MATLAB graphics commands are used.

SNOWFALL_HISTOGRAM makes a histogram of the yearly snowfall totals at Michigan Tech from 1890 to 2017. MATLAB graphics commands are used.

SNOWFALL_PLOT makes a line plot of the snowfall at Michigan Tech from 1890 to 2017. MATLAB graphics commands are used.

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. MATLAB graphics commands are used.

TEMPERATURE_SCATTER shows locations in the US where the January temperature was recorded. MATLAB graphics commands are used.

TEMPERATURE_SCATTER3D shows temperatures and locations in the US where the January temperature was recorded. MATLAB graphics commands are used.

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. MATLAB graphics commands are used.

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. MATLAB graphics commands are used.

VOLCANO_COLOR_CONTOUR displays a color contour plot of local elevation around a volcano.

VOLCANO_CONTOUR displays a line contour plot of local elevation around a volcano.

VOLCANO_SURFACE displays a surface plot of local elevation around a volcano.

WEB_DIGRAPH displays a set of directed connections as a digraph. MATLAB graphics commands are used.

You can go up one level to the MATLAB source codes.