Setting limits of the y-axis using plot_marginal function

30 views
Skip to first unread message

Gareth Walker

unread,
Jul 4, 2022, 7:51:02 AM7/4/22
to unmarked
Good day all,

Is it possible to set y-limits within the plot_marginal function of ubms? I have run separate occupancy models for seven feeding guilds and want to compare them visually. I have tried a few different options but am yet to get the desired output. Any suggestions would be greatly appreciated.

Regards
Gareth

Ken Kellner

unread,
Jul 4, 2022, 7:58:27 AM7/4/22
to unma...@googlegroups.com
Hi Gareth,

The output of plot_marginal is a ggplot object, so you should be able to add additional ggplot options to it, e.g. ylim()

library(ggplot2)

plot_marginal(model, 'state') + ylim(0, 0.5)

You have to be on the most recent CRAN version of ubms for this to work.

Ken
> --
> *** Three hierarchical modeling email lists ***
> (1) unmarked (this list): for questions specific to the R package unmarked
> (2) SCR: for design and Bayesian or non-bayesian analysis of spatial capture-recapture
> (3) HMecology: for everything else, especially material covered in the books by Royle & Dorazio (2008), Kéry & Schaub (2012), Kéry & Royle (2016, 2021) and Schaub & Kéry (2022)
> ---
> You received this message because you are subscribed to the Google Groups "unmarked" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to unmarked+u...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/unmarked/a6d39206-a77e-45d6-b7d5-26994b25d52fn%40googlegroups.com.

Gareth Walker

unread,
Jul 4, 2022, 9:11:29 AM7/4/22
to unma...@googlegroups.com
Hi Ken,

Thanks for the swift response. I will give that a bash now. 

Cheers
Gareth

Gareth Walker

unread,
Jul 4, 2022, 9:48:11 AM7/4/22
to unma...@googlegroups.com
Apologies Ken however it still seems to give me a "NULL" output. I have made sure that my CRAN version of ubms is up to date as well as all associated packages. I am modelling the output of two covariates at the same time (i.e. season and habitat), could this be the reason as to why it is not changing the ylim?

Ken Kellner

unread,
Jul 4, 2022, 3:11:36 PM7/4/22
to unma...@googlegroups.com
Hi Gareth,

Yes, if you have multiple covariates on the same plot then the output isn't a ggplot object and there isn't really an easy way to modify one individual component plot or the other after the fact. I'd suggest running plot_marginal for one covariate at a time and then combining the resulting plots yourself (e.g. with gridExtra::grid.arrange or the cowplot package) or perhaps take a look at the source code for plot_effects/plot_marginal and customize it for your specific situation.

Ken
> To view this discussion on the web visit https://groups.google.com/d/msgid/unmarked/CAPZAkGE48ZfLpcNArRgcpGT_g%2BE%3DZNdR34_XstmL2EiZi0s4Yw%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages