【发布时间】:2017-11-17 00:02:09
【问题描述】:
我想根据 y 轴约为 0.5 的 x 轴值,按每条彩色曲线的顺序对数据集进行排序。现在的图例是基于顺序的。但是,如果您对数据进行正确排序,则图例应类似于 [item 5, item 1, item 3, item 2, item 4]。
library(mirt)
dat <- expand.table(LSAT7)
mod <- mirt(dat, 1)
plt <- plot(mod, type = 'trace', facet_items=FALSE) #store the object
print(plt) #plot the object
str(plt) #find the data
plt$panel.args
pltdata <- data.frame(lapply(plt$panel.args, function(x) do.call(cbind, x))[[1]])
pltdata$item <- rep(colnames(dat), each = 50)
library(ggplot2)
ggplot(pltdata, aes(x, y, colour = item)) +
geom_line() +
ggtitle('ggplot2 Tracelines') +
xlab(expression(theta)) +
ylab(expression(P(theta))) +
geom_hline(aes(yintercept = 0.5))
【问题讨论】: