andrewcparnell/Bchron

plot.BchronologyRun not recognizing normal plot arguments

Closed this issue · 7 comments

Hi Andy. Beginning in some recent version plot.BchronologyRun stopped recognizing standard plot arguments xlab, ylab, main, and cex.

It also does not seem to be producing a plot object that is recognized by subsequent plot commands like abline or axis. When these are run immediately after plot.BchronologyRun, it generates the error: "plot.new has not been called yet". So there is no way to modify the plot.

I updated to bchron 4.7.5 and R 4.0.5 and have the newest Mac OS.

Hi Michael,

Apologies this changed a few versions ago but I don't think I documented it well. You can customise the plots by adding on standard ggplot2 commands. Here's a reproducible example:

library(Bchron)
library(ggplot2)
data(Glendalough)
GlenOut = with(Glendalough, 
               Bchronology(ages=ages,
                           ageSds=ageSds, 
                           calCurves=calCurves,
                           positions=position, 
                           positionThicknesses=thickness,
                           ids=id, 
                           predictPositions=seq(0,1500,by=10)))
plot(GlenOut) +
  labs(title = "Glendalough",
       x = "Age (cal years BP)",
       y = "Depth (cm)")

I've updated the documentation and the manual to make this clearer.

Thanks. ggplot2 commands will be very nice. Is this the case for all bchron plots now?

It is for the functions which use ggplot2, which I think is all of them apart from plot.BchronDensityRun. One day I'll get round to improving that function too.

Plot labels are not working in the current github version. Running the example in the comment above with version 4.7.6 does add a plot title, but leaves x and y axis labels as the default "Age" and "Position".

Thanks for spotting this - there was a typo in the above code snippet (should have been x and y instead of xlab and ylab). I've edited it and it should work now.

Andrew

Can't believe I missed this! I had used the correct parameters earlier in the same document. Would be nice if ggplot returned a warning if unknown parameters are passed to labs(). I noticed the BChron vignette has the same typo. I'll submit a PR to fix. Thanks!

Doubly well spotted!