Plotting in R

#1
Dear all,
I am new to R and am trying to draw some plots in R. I am not able to figure out how to control the labels and marks(positions,number) of ticks ticks, and also how to restrict the length of trendline to the dataset. I also have a few other minor questions. Can someon eplease help me with the above questions and/or post any plotting script from which I can learn how to do things?
Thank you very much,
Cheers
 
#2
Hope this helps.. It's a lot but I think you can decipher what each line does. Others will hate that I'm showing you ggplot, everything here can be done in base, but for just starting out, you might find this easier. Also check out yeroon, it's a fast and easy way to get started.

Code:
require(ggplot2)


ggplot() +
	geom_path(data=cars, aes(x=speed, y=dist, colour="coral2"), size=1.8) + 
	geom_point(data=cars, aes(x=speed, y=dist), colour="white", shape=2, size=1.2) +
	theme_bw() +
	xlab("X Label") + 
	ylab ("Y Label") +
	scale_colour_manual(values=c("darkred","darkblue")) +
	theme(legend.position=c(.75,.815), legend.direction = "vertical", legend.box = "horizontal") +
	theme(axis.title.x=element_text(vjust=-0.5)) +				# adjust x axis label down
	theme(axis.title.y=element_text(hjust=0.5))  +				# adjust y axis lable left
	theme(panel.grid.major=element_line(colour="grey80", size=0.5)) +	# adjust major grid color and size
	theme(panel.grid.minor=element_line(colour="grey95", size=0.4)) +	# adjust minor grid color and size
	scale_x_continuous(minor_breaks=seq(0,5,by=0.25)) +			# adjust x minor grid spacing
	scale_y_continuous(minor_breaks=seq(0,50,by=5)) +			# adjust y minor grid spacing
	theme(panel.border=element_rect(colour="black",size=.75)) +		# adjust border color and size
	theme(legend.background = element_rect(fill="azure2"))
 
#5
Thanks Nathan for giving details about ggplot. I tried to do a bit using that and it appears to be useful. But I also need to learn to write the code as I may have to do many complicated things.
Thanks Trinker, I found the answers to my first question but I am still searching for a way to restrict the trendline to the dataset and not allowing it to touch the axes to form the intercepts.
Thanks bugman, I am doing a simple linear regression and plotting the results. But I do not want the trendline to touch the axes.
Please inform me if you know the solution,
Thank you.