plot(cars)
plot(x, y)where x is the independent variable vector and y is the dependent variable vector. We can use the plot function with two input parameters like this:
x <- cars[,1] y <- cars[,2] plot(x, y)
Parameter | Description |
---|---|
main | Title of the plot at top of graph |
sub | Subtitle of the plot at the bottom of graph |
xlab | Label for x-axis |
ylab | Label for y-axis |
asp | Aspect ratio of data ranges |
xlim | Mininum and maximum of x-axis range |
ylim | Mininum and maximum of y-axis range |
pch | Plotting symbol (character or numeric value from 1 to 25) |
col | Color of plotting symbol |
type | Type of plot1 |
x = cars[ ,1] y = cars[ ,2] plot(x, y, main="Cars Dataset", sub="Data from 1920s", xlab="Speed (mph)", ylab="Stopping Distance (feet)", xlim=c(0, 30), ylim=c(0, 130), pch="*", col="red")
> pdf("mygraph.pdf") # Create PDF file. > png("mygraph.png") # Create PNG file. > jpeg("mygraph.jpg") # Create JPEG file. > bmp("mygraph.bmp") # Create BMP file. > postscript("mygraph.ps") # Create Postscript file.
adj ann *ask *bg bty cex cex.axis cex.lab cex.main cex.sub cin col col.axis col.lab col.main col.sub cra cxy family fg *fig *fin font font.axis font.lab font.main font.sub lab las lend *lheight ljoin lty lwd *mai *mar *mex *mfcol *mfrow mgp *new *oma *omd *omi pch *pin *plt *ps *pty srt tck tcl usr xaxp xaxs xaxt *xlog xpd xaxp yaxs yaxt *ylbias *ylog
col="DarkKhaki"
col="#808000"
col=heat.colors(4)uses the first four colors of the heat.colors palette "#FF0000FF", "#FF8000FF", "#FFFF00FF", "#FFFF80FF". (The fourth component of each color is the alpha component, which is the transparency.
palette(c("red", "green", "blue"))
height Width space names.arg legend.text beside horiz density angle col border main sub xlab ylab xpd log cex.axis cex.names plot
x labels edges radius init.angle density angle col border lty mainSee the PieCharts Example.
x labels groups gdata cex pch gpch bg color gcolor lcolor xlim main xlab ylabSee the DotCharts Example.
x breaks freq include.lowest right density angle col border main xlab ylab xlim ylim axes plot labels
scores = rnorm(85, mean=100, sd=15)
formula data subset x range width varwidth notch outline names boxes plot border col log horizontal add at