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 pen command:

x = np.arange(-10, 10, 0.1)

qp.pen('r', 2, pattern='solid')

qp.plot(x, np.sin(x))

qp.pen('b', 2, pattern='dot')

qp.plot(x, np.cos(x))

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

The pen 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 = np.arange(-10, 10, 0.5)

qp.penqp.pen('r', 2)

qp.brushqp.brush('955')

qp.skyline(x, np.sin(x))

x = np.arange(-10, 10, 0.5)

qp.pen('none')

qp.brush('559')

qp.bars(x, np.sin(x), 0.33)

These examples also introduced the brush command and an alternate way of specifying color: as a triplet of RGB digits. You can also specify colors as a tuple like (0.5, 0.5, 1).

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