Combining plots

So far, we plotted a very basic graph of a sinusoid. Now, we will combine two plots, and we will need to make them look visually distinct. This is done using the qpen command:

x = -10:0.1:10;

qpen r 2 solid

qplot(x, sin(x));

qpen b 2 dot

qplot(x, cos(x));

(Note again that specifying the plotting style must occur before plotting the data.)

The qpen command takes many kinds of arguments; the most important ones are color, specified as a single letter Matlab-style color name; line width, specified in printer’s points (1/72th of an inch); and pattern.

In addition to simple line series plots as shown above, QPlot can also produce skyline plots and bar graphs:

x = -10:.5:10;

qpen r 2 solid

qbrush 955

qskyline(x, sin(x));

x = -10:.5:10;

qpen none

qbrush 559

qbars(x, sin(x), 0.33);

These examples also introduced the qbrush command and an alternate way of specifying color: as a triplet of RGB digits.

(C) Daniel Wagenaar, 2014. This web page is licensed under the GNU Free Documentation License.