Skip to content

Instantly share code, notes, and snippets.

@epijim
Created September 10, 2013 13:56
Show Gist options
  • Save epijim/6509760 to your computer and use it in GitHub Desktop.
Save epijim/6509760 to your computer and use it in GitHub Desktop.
2 categories
#--The following was used to define the colours, but since it's a non-standard
# package, I've used the hexadecimal colour codes explicity below to avoid the
# need to install "RColorBrewer". See http://colorbrewer2.org/ for more info.
#require(RColorBrewer)
#colset <- brewer.pal(3, "Pastel2")
colset <- c("#B3E2CD", "#FDCDAC", "#CBD5E8")
path <- "http://www.sr.bham.ac.uk/~ajrs/R/datasets"
#--Data file as taken from XMM website, but with "#" added to comment lines
file <- paste(path, "ao7_otac_by_radec.txt", sep="/")
#--Read in data (default behaviour is to treat non-numeric entries as
# factors, which is what's required here)
A <- read.fwf(file, widths=c(8, -3, 1, -3, 31, 18, 10, -2, 10, -3, 6, -4, 1, -4, 1, -9, 1))
colnames(A) <- c("obsid", "cat", "PI", "target", "ra", "dec", "t.exp", "N", "pri", "fix")
pdf("XMM_AO7_summary.pdf", height=8.25, width=8.25, pointsize=16)
#--Specify layout for 2 plots (1 for science category legend)
layout(matrix(1:2, 2, 1, byrow=TRUE), heights=c(1, 0.4))
#layout.show(2) # Not run here, but would show size & positions of plot regions
#--Since the X & Y data are factors, "plot" produces a "spineplot()"
par(las=1) # Orient all axis labels horizontally
par(mar=c(5, 4, 4, 2.2) + 0.1) # Widen right margin slightly, to fit horizontal labels
plot(pri ~ cat, data=A, col=colset, main="XMM AO7 accepted proposals",
xlab="Science Category", ylab="Priority")
#--Plot nothing at all, to allow legend to be added:
par(mar=c(0, 1, 0, 1)) # Reduce plot margins
plot.new()
legend(x="topleft", cex=0.7, c("A: Stars, White Dwarfs and Solar System",
"B: White Dwarf Binaries, Neutron Star Binaries, Cataclysmic Variables, ULXs and Black Holes",
"C: Supernovae, Supernova Remnants, Diffuse (galactic) Emission and Isolated Neutron Stars",
"D: Galaxies and Galactic Surveys","E: Active Galactic Nuclei, Quasars and BL-Lac Objects",
"F: Groups of Galaxies, Clusters of Galaxies and Superclusters",
"G: Cosmology, Extragalactic Deep Fields and Area Surveys"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment