Hi Bruce & Abby, Here is a start on merging the two plots. Abby - I had to cheat on the legend colors as I could not work out from the help pages how to specify the range of colors. Also I don't know the range of densities. Both should be easy to fix. While I specified xlab and ylab, they don't seem to make it to the plotting functions. More study needed. Bruce - The following code gives general idea of how to automate plotting from a single data set. let me know whether you want automated adjustment of axes, etc. Both - I suspect that the constraints forming the diagonal lines are due to characteristics of the bat larynx.
bfs<-read.csv("Procen_sample.csv") # split out what you want to identify the plot species<-unlist(strsplit("Procen_sample.csv","_"))[1] library(bivariate) # define the plot sequence plot_ds <- function (dataset, main="", xlim, ylim, ..., k1=1, k2=1) { names <- names (dataset) fh <- kbvpdf (dataset [,1], dataset [,2], k1 * bw.nrd (dataset [,1]), k2 * bw.nrd (dataset [,2]) ) plot (fh, main=main, xlab = names [1], ylab = names [2], xlim=xlim, ylim=ylim, ncontours=2) } # open the device png(paste0(species,".png")) # leave space for the color legend par(mar=c(6,4,4,2)) plot_ds (bfs[,c("Fc","Sc")], main=paste(species,"characteristic bat call"), xlab="Frequency (kHz)",ylab="Characteristic slope (octaves/s)", ,k1=1.25, k2=1.25) library(plotrix) xylim<-par("usr") color.legend(xylim[1],xylim[3]-(xylim[4]-xylim[3])/7, xylim[1]+(xylim[2]-xylim[1])/4,xylim[3]-(xylim[4]-xylim[3])/10, legend=seq(0,10,length.out=5), rect.col=color.scale(0:4,extremes=c("#7be6bd","#bdb3df")),align="rb") text(xylim[1]+(xylim[2]-xylim[1])/8, xylim[3]-(xylim[4]-xylim[3])/5, "Density",xpd=TRUE) dev.off() Jim On Wed, Jun 3, 2020 at 6:22 AM Neotropical bat risk assessments <neotropical.b...@gmail.com> wrote: > > Hi Abby, > > The contour lines are actually useful to see groupings. > However w/o a legend for density it is not possible to see what is > presented. > >> Very nice > > Jim, thank you. > > However, the (deterministic, or near-deterministic) diagonal lines in > > the plot, make me question the suitability of this approach. > > In my plot, the contour lines could be removed, and brighter colors > > could be used. > > > > But perhaps, a better approach would be to model those lines... > > And it's not clear from the plot, if all the observations fall on a > > diagonal line... > > > > > > P.S. > > I'm not sure why there's a white line on the plot. > > Most of my testing was with PDF output, I will need to do some more > > testing with PNG output. > > > -- > Bruce W. Miller, PhD. > Neotropical bat risk assessments > Conservation Fellow - Wildlife Conservation Society > > If we lose the bats, we may lose much of the tropical vegetation and the > lungs of the planet > > Using acoustic sampling to identify and map species distributions > and pioneering acoustic tools for ecology and conservation of bats for >25 > years. > > Key projects include providing free interactive identification keys and call > fact sheets for the vocal signatures of New World Bats >
______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.