# Plotting

Need data in the right format first

Check it!!

This load a data.txt file to be read as a table from the t drive in folder “Data”. header=T means the top rows are the names of the columns.

This data is now attach to data

enter data1

Getting attached

Attach it for more semi permanent use

attach(data1) #attach data to data1

Call data by the heading names instead of data\$fish you would just use fish

names(data1) #attach data1 to names

Simple things first

x<-1:10

y<-c(11,12,9,7,5,8,4,4,5,3)

plot(x,y)

xlab is for the x axis (bottom one)

ylab is for the y axis (side one)

plot(x,y,ylab=’Response variable’,xlab=’Explanatory variable’)

Change colour of the points

plot(x,y,col=”red”)

Change the points

plot(x,y,pch=3)

http://rgraphics.limnology.wisc.edu/index.php

abline(lm(y~x))

~ tilda

y=Response variable

x=Explanatory variable

Draw a line

lines(c(0,10),c(12,0),lty=2))

#draw a line when y=12 x=0 and when y=0 and x=10

load new data, label it and add them as points, change the colour, point shape to show that its different

points(x1,y1,col=’green’, pch=5)

Merge data on one graph

plot(c(x,x1),c(y,y1),xlab=’x’,ylab=’y’,type=”n”) #plotting a blank axis but the right size

points(x,y,col=’pink’) #plot x and y data in pink

points(x1,y1,col=’green’) #plot x1 and y1 data in green