[R] Query on contour plots

Jim Lemon drj|m|emon @end|ng |rom gm@||@com
Tue Jun 2 12:20:10 CEST 2020


Very nice. I forgot that you didn't have the complete data set.

png("as_bat_call.png")
plot_ds (bfs[,c("Fc","Sc")], "plot 1", xlim = c (25, 30), ylim = c (-15, 10),
        k1=1.25, k2=1.25)
dev.off()

Jim

On Tue, Jun 2, 2020 at 6:24 PM Abby Spurdle <spurdle.a using gmail.com> wrote:
>
> I'm putting this back on the list.
>
> > So how would I set up the code to do this with the data type I have?
>
> > I will need to replicate the same task > 200 times with other data sets.
> > What I need to do is plot *Fc *against *Sc* with the third dimension being the *density* of the data points.
>
> Using Jim's bat_call data:
>
>     library (bivariate)
>
>     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)
>     }
>
>     plot_ds (bat_call, "plot 1", k1=1.25, k2=1.25)
>
> Note that I've used stats::bw.nrd.
> The k1 and k2 values, simply scale the default bandwidth.
> (In this case, I've increased the smoothness).
>
> If you want to do it 200+ times:
> (1) Create another function, to iterate over each data set.
> (2) If you want to save the plots, you will need to add in a call to
> pdf/png/etc and close the device, in each iteration.
> (3) It may be desirable to have constant xlim/ylim values, ideally
> based on the ranges of the combined data:
>
>     plot_ds (bat_call, "plot 1", xlim = c (25, 30), ylim = c (-15, 10),
>         k1=1.25, k2=1.25)
>
> ______________________________________________
> R-help using 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.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: as_bat_call.png
Type: image/png
Size: 26580 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20200602/17c1cb64/attachment.png>


More information about the R-help mailing list