Skip to content

Commit

Permalink
Merge pull request #76 from abidawson/grouping-histograms
Browse files Browse the repository at this point in the history
Match histograms with likert barplot when using group.order to set item order
  • Loading branch information
jbryer committed Nov 27, 2017
2 parents 54a6c00 + c750fb8 commit 1d76bc3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions R/plot.histogram.R
Expand Up @@ -95,6 +95,12 @@ likert.histogram.plot <- function(l,
limits=c(TRUE,FALSE),
labels=c(label.missing, label.completed),
values=c(missing.bar.color, bar.color))

if(!missing(group.order)){
p <- p + scale_x_discrete(limits=rev(group.order),
labels=label_wrap_mod(rev(group.order), width=wrap), drop=FALSE)
}

} else {
hist <- data.frame( )
for(g in unique(l$grouping)) {
Expand Down
6 changes: 6 additions & 0 deletions R/plot.likert.bar.r
Expand Up @@ -204,6 +204,12 @@ likert.bar.plot <- function(l,
order <- lsum[order(lsum$high),'Item']
results$Item <- factor(results$Item, levels=order)
}


if(!ordered & !missing(group.order)) {
results$Item <- factor(results$Item , levels = group.order)
}

ymin <- 0
if(centered) {
ymin <- -100
Expand Down

0 comments on commit 1d76bc3

Please sign in to comment.