options(digits = 7)  # knitr sometimes decreases number of digits shown
require(stats)
xgrid <- c(1e-17,1e-16,1e-15,1e-14,1e-13,1e-12);


postscript(paste("../../products/eUDS_4XMM-DR12.flux.eps",sep=""), horizontal = FALSE, onefile = FALSE, paper = "special",width = 9.0, height = 6.0)
par(oma=c(1,1,1,1))

#layout(matrix(c(1,2), 2, 1, byrow = TRUE), heights = c(1.5,1), TRUE)

par(mar=c(4.3, 4.3, 1, 1))
par(cex.lab=1.2)
par(cex.axis=1.2)

a <- read.table("../../products/eUDS_4XMM-DR12.flux.cvs", col.names=c("eflux","eerr","xflux","xerr"))


xlim <- c(1e-15,1e-12)
ylim <- c(1e-16,1e-12)

plot(NULL,  pch=21, bg="gold",ylim=ylim, xlim=xlim, main="", ylab="eUDS, erg/s/cm2",type="p",xaxt="n",xlab="4XMM-DR12, erg/s/cm2", log="xy")
axis(side=1, at=xgrid, labels=xgrid)
segments(a$xflux,a$eflux-a$eerr,a$xflux,a$eflux+a$eerr)
segments(a$xflux-a$xerr,a$eflux,a$xflux+a$xerr,a$eflux)
#segments(a$xlo,d,a$xhi,d)
points(a$xflux,a$eflux,pch=21, bg="gold")


lines(c(1e-17,1e-12),c(1e-17,1e-12))
lines(c(1e-17,1e-12),10*c(1e-17,1e-12),lt=2)
lines(c(1e-17,1e-12),0.1*c(1e-17,1e-12),lt=2)

grid()



abline(h=0, col = "black",lty=2)
abline(v=xgrid, col="lightgray", lty="dotted")

dev.off()
