Line Widths and Marker Sizes

Next in this discussion of customization is controlling line widths and marker sizes. This is done by passing linewidth (or lw for short) and markersize (or ms for short) arguments to plot(), as shown in Listing 6-1. Both arguments accept a floating-point value; the default value is 1.

Listing 6-1. Plotting Several Lines in One Graph with Different Line Styles and Markers I = arange(6)

plot(I, sin(I), 'o', I, cos(I), lw=3, ms=8) title("plot(I, sin(I), 'o', I, cos(I), lw=3, ms=8)")

Figure 6-3 shows the results of this example.

Figure 6-3. Plotting several graphs in one figure

When you plot multiple lines in one plot() function call, the parameters linewidth and markersize control all the lines in the same plot() command. If you'd like different lines with different line styles or different marker sizes in the same figure, draw each plot with an individual call to the plot() function and use the hold() function, as shown in Listing 6-2.

Listing 6-2. Different Line Widths in One Graph figure(); hold(True) I = arange(6) plot(I, sin(I), lw=4) plot(I, cos(I) , lw=2)

Was this article helpful?

0 0

Post a comment