Auto PNG of adjusted bi valued plot

##load the required bits
library(RODBC) ##for DB connection
library(doBy) ##for summaryBy
library(grDevices)## for outpur to PNG
channel<-odbcConnect("mike_db", uid="mike")
a<-sqlFetch(channel,"AnE_ind")
c<-summaryBy(wait~month_val,data=a, FUN=function(x){c(mean=mean(x),sd=sd(x),l=length(x),m=median(x))})
###########################
png(width = 750, height = 500,units="px",file="Z:/PLOTS/myplot3.png",bg="white")
par(mar=c(5, 4, 4, 5) + 0.1) ##add a margin to all subsequent charts
plot(
wait.l~month_val,data=c, type="l",lwd=1,col="blue"
,ylim=c(0,max(wait.l)+0) 
	, xlab="Date", ylab=""
	,main="YG Monthly A&E Attendance (Blue) 
	with Median Wait in minutes (Red)" 	)
par(new=T)
plot(wait.m~month_val,data=c,axes="F", type="l",lwd=1,ylim=c(0,max(wait.mean)+0)
,col="red",ylab="", xlab="")
mtext("Median Time Arrival to Discharge (mins)", col="red",4,2.4) ##"text", colour,side , offset
axis(side=4)
mtext("Monthly Attendance", col="blue",2,2.4)
axis(side=4)
dev.off()
########################################
ygts<-ts(c$wait.l,frequency=12)
plot(decompose(ygts))
########################################
ygMts<-ts(c$wait.m,frequency=12)
plot(decompose(ygMts))
########################################