[R] basic graphics

Ross Ihaka ihaka at stat.auckland.ac.nz
Mon Dec 7 23:25:36 CET 1998

Here is a simple example showing how to use colors and symbols:

	# create some fake data, x, y, and group
	x <- runif(100)
	y <- runif(100)
	g <- rep(1:4, 25)

	# colors: plot with col=1 for group1, col=2 for group2 ...
	plot(x, y, col=g)

	# symbols: plot with pch=1 for group1, pch=2 for group2 ...
	plot(x, y, pch=g)

	# Both colors and symbols
	plot(x, y, col=g, pch=g)

	# customised colors and symbols
	plot(x, y, col=c("red","green","blue","yellow")[g])
	plot(x, y, pch=c(1,3,7)[g])

To see why these last two work, just print the value of


Hope this helps.
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch

More information about the R-help mailing list