Black and White theme has incorrect legend

138 views
Skip to first unread message

Daniel McKelvey

unread,
Jun 9, 2018, 2:33:46 PM6/9/18
to mirt-package

Hi everyone,


I wasn't sure if here would be the best place to ask this, but I couldn't find a lattice specific forum, so I thought I would start here. I have been having difficulties with converting plots to the Black and White theme, and I've attached an example plot to show what I mean. I have tried a couple of ways to convert to that theme, and when I do the plots do not match the legend. At first I was wanting to change the legend to match the plot, but I just realized that the plots repeat themselves, so I was actually wondering if there might be a way to change the plots to match the legend perhaps with a trace line through the corresponding shapes.

The plot was created after first running this, which I found elsewhere in this forum:
trellis.device()
trellis.par.set(list(plot.line = list(col = "black")))

Thanks
Daniel McKelvey





Phil Chalmers

unread,
Jun 9, 2018, 4:49:58 PM6/9/18
to Daniel McKelvey, mirt-package
Interesting question. It looks like lattice doesn't track colour/theme changes very well (this is where I sometimes wish the plots in mirt were written with ggplot2). In your plot you need to modify the output type as well in the legend, which is generated by the auto.key input. Here's an example:

library(mirt)
mod <- mirt(Science, 1)
trellis.device(color=FALSE)
itemplot(mod, 1, type = 'trace', auto.key=list(points=FALSE, lines=TRUE))

I suppose in mirt the legend should be using lines by default anyway rather than points, so perhaps I'll change this internally to ensure everything is kosher where it should be. Cheers.

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.
For more options, visit https://groups.google.com/d/optout.

Daniel McKelvey

unread,
Jun 10, 2018, 2:37:17 PM6/10/18
to mirt-package
Thanks Phil! That changed the legend to match the lines. One issue is that P1 and P7 lines match in terms of pattern (i.e. they are both solid lines). I think that it should not be too much of an problem since it is pretty clear which is which, but would you be aware of a way to accomplish the reverse of this (i.e. change the trace lines to match the original legend shapes)?

Phil Chalmers

unread,
Jun 10, 2018, 9:51:16 PM6/10/18
to Daniel McKelvey, mirt-package
Another annoying thing, but I learned a few new things about lattice....so that good. See below:

library(mirt)
mod <- mirt(Science, 1)
theme <- simpleTheme(lty=1:2, col='black')
itemplot(mod, 1, type = 'trace', auto.key=list(points=FALSE, lines=TRUE),
               par.settings=theme)


Phil

Reply all
Reply to author
Forward
0 new messages