0

I have 11 data columns in a single data.frame, 10 of the columns are depth categories and one column contains one of two values (Day or Night).

Each row of data is populated with numeric values representing the percent of time spent in each depth category over a 4-hour period and has either Day or Night assigned to it in the Day_Night column indicating whether that 4-hour period was during the day or the night.

I would like to plot this data in a back to back histogram where each depth bin is listed vertically along the plot and values for the day are plotted in one histogram facing one way, while the values for the night are plotted facing the other way. I can't post a picture since I am new but to see what I mean just look at Figure 5 on page 8 of this publication.

EDIT: Here's the picture:

enter image description here Thanks for the help!

Chris McFarland
  • 6,059
  • 5
  • 43
  • 63
2ton21
  • 189
  • 1
  • 1
  • 11
  • Can you provide some reproducible data? What have you tried so far? What is the exact problem you are having? http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example Generally SO questions target detailed specifics, rather than a 'how can I do this'? You need to help us help you! – thelatemail Aug 09 '13 at 01:05

1 Answers1

0

You can use plotrix for example:

set.seed (123)
mm <- matrix (sample(seq(0,330,10),2000,rep=TRUE),ncol=2 )
ll <- lapply(as.data.frame(mm),
       function(x)as.data.frame(table(cut(x,seq(0,330,10)))))


library(plotrix)
par(mar=pyramid.plot(ll$V1$Freq,ll$V2$Freq,
                     labels =ll$V1$Var1,
                     top.labels=c("NIGHT","","DAY"),
                     xlim=c(100,100),
                     main="Swimming depth",
                     lxcol="black",rxcol= "white",
                     gap=0,
                     do.first="plot_bg('pink')"))

enter image description here

agstudy
  • 119,832
  • 17
  • 199
  • 261
  • This is very close, but my problem is plotting my data which is in unequal bins. Ex of my data: structure(list(Day_Night = structure(c(1L, 1L, 1L), .Label = c("Day", "Night"), class = "factor"), `0-10` = c(100, 17.3, 0), `25` = c(0, 0, 0.6), `50` = c(0, 82.2, 83.8), `75` = c(0, 0.6, 12.8), `100` = c(0, 0, 2.8), `125` = c(0, 0, 0), `150` = c(0, 0, 0), `200` = c(0, 0, 0), `250` = c(0L, 0L, 0L), `300` = c(0L, 0L, 0L), `1000` = c(0L, 0L, 0L)), .Names = c("Day_Night", "0-10", "25", "50", "75", "100", "125", "150", "200", "250", "300", "1000"), row.names = c(NA, 3L), class = "data.frame") – 2ton21 Aug 09 '13 at 17:41