Re: [R] Plotting lines with shapes

From: Marc Schwartz <>
Date: Tue 21 Jun 2005 - 08:42:34 EST

On Mon, 2005-06-20 at 16:44 -0400, Hikel, Jerry wrote:
> I am currently attempting to work on some graphs whose plotted lines
> have simple polygons at regular intervals, such as a triangle or a
> square.
> I haven't been able to find anything in the base R plotting packages, or
> in any extensions that would allow me to do this easily. I am familiar
> with polygon drawing and shading, but i was wondering if anyone knew of
> any packages that have these types of graphing capabilities built in to
> the line functions themselves. Thanks.

There are multiple approaches here, but using the base graphics package:

# plot type = 'b' uses both lines and symbols plot(10:30, type = "b", pch = 24, bg = "black")

plot(10:30, type = "b", pch = 22, cex = 1.5)

You also have the option of doing them separately, which may give you more control in some situations:

  1. Draw the line(s) first and then add the symbols:

 plot(10:30, type = "l")
 points(10:30, pch = 22, bg = "black")

2. Draw the symbols and then add the line(s):

 plot(10:30, pch = 24, bg = "black")

See ?plot.default, ?lines and ?points for more information on plots and symbols. Note the 'cex' and 'bg' arguments, which enable you to adjust the size of the symbols and the fill color for the symbols.

HTH, Marc Schwartz mailing list PLEASE do read the posting guide! Received on Tue Jun 21 08:46:51 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:32:54 EST