Stacking itemplot() with patchwork or plot_grid()

6 views
Skip to first unread message

Oliver D. Reithmaier

unread,
Apr 14, 2025, 7:06:37 AMApr 14
to mirt-package
Hi,

I was just wondering whether it would be possible to directly stack the plot outputs of itemplot() with package functions like patchwork or plot_grid() from cowplot. I was trying a bit and - as far as I can tell from the source code, mirt passes the parameters of the plot to lattice's xyplot...this should be includable in plot_grid() but I can't figure out how to exactly do this, because all itemplot() produces object wise is a parameter list. Is there a shortcut that I'm missing or do I need to feed all the parameters into xyplot manually?

Best,
Oliver

Phil Chalmers

unread,
Apr 25, 2025, 2:58:59 PMApr 25
to Oliver D. Reithmaier, mirt-package
patchwork should be able to do this, but you'll have to convert the objects from lattice to ggplot2 first. Here's an example:

###
library(mirt)
library(ggplotify)

mod <- mirt(Science)
itemplot(mod, 1) |> as.ggplot() -> i1
itemplot(mod, 2) |> as.ggplot() -> i2

library(patchwork)
i1 + i2
###

HTH.

Phil


--
You received this message because you are subscribed to the Google Groups "mirt-package" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mirt-package...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/mirt-package/911e55d5-7e52-4453-940a-145b4f28d5c7n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages