Categories
Uncategorized

Log Graph Function – R

log.graph<-function(data,title,xlab='',ylab='Posts'){
	plot(
		# Takes data from data.frame
		# in column 2
		c(t(data[2])),
		# This is the log bit
		log='xy',
		# Labels for graph
		xlab=xlab,
		ylab=ylab,
		# Graph title
		main=title,
		# Suppresses any x labeling
		xaxt="n",
		)

		# This part creates the cool
		# lines in the graph
		abline(
    		h   = c( seq( 1, 9, 1 ), 
				seq( 10, 90, 10 ), 
				seq( 100, 1000, 100 ) 
				),
    		lty = 3,
    		col = 'gray87'
			)

		# Drawing the above lines deletes
		# original plot, so this redraws them
		points( c(t(df[2])) )
}

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s