Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes alignment of boxplots in Boxplot.R #208

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions R/Boxplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
IntersectionBoxPlot <- function(data1, data2, start_col, names){
end_col <- ((start_col + length(names)) - 1)
data2 <- data2[which(rowSums(data2[ ,start_col:end_col]) != 0), ]
#tagging because x axis values need to be 1:number of sets so they line up with their intersections
data2$tag <- 1:nrow(data2)
sets <- list()
intersections <- list()
Expand Down Expand Up @@ -42,16 +41,22 @@ BoxPlotsPlot <- function(bdat, att, att_color){
bdat$x <- as.factor(bdat$x)
boxplots <- ggplotGrob(ggplot()
+ theme_bw() +ylab(yaxis)
+ scale_x_discrete(limits = plot_lims, expand = c(0,0))
+ scale_x_discrete(limits = factor(plot_lims), expand = c(0,0))
+ theme(plot.margin = unit(c(-0.7,0,0,0), "cm"),
axis.title.y = element_text(vjust = -0.8),
axis.title.y = element_text(vjust = -0.6, size = 10),
axis.ticks.x = element_blank(),
axis.text.x = element_blank(),
panel.border = element_blank(),
panel.grid.minor = element_blank(),
panel.grid.major = element_blank(),
axis.title.x = element_blank())
+ geom_boxplot(data = bdat, aes_string(x="x", y="attribute"),
fill = att_color, colour = "gray80"))
fill = att_color, colour = "gray43",
outlier.size = 0.3
, notch = TRUE
)
+ geom_hline(aes(yintercept = median(bdat$attribute, na.rm = TRUE)), alpha = 0.3)

)
return(boxplots)
}
}
4 changes: 2 additions & 2 deletions R/MainBar.R
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ Make_main_bar <- function(Main_bar_data, Q, show_num, ratios, customQ, number_an
+ xlab(NULL) + ylab(ylabel) +labs(title = NULL)
+ theme(panel.background = element_rect(fill = "white"),
plot.margin = unit(c(0.5,0.5,bottom_margin,0.5), "lines"), panel.border = element_blank(),
axis.title.y = element_text(vjust = -0.8, size = 8.3*y_axis_title_scale), axis.text.y = element_text(vjust=0.3,
size=7*y_axis_tick_label_scale)))
axis.title.y = element_text(vjust = -0.8, size = 10*y_axis_title_scale), axis.text.y = element_text(vjust=0.3,
size=10*y_axis_tick_label_scale)))
if((show_num == "yes") || (show_num == "Yes")){
if(is.null(number.colors)) {
Main_bar_plot <- (Main_bar_plot + geom_text(aes_string(label = "freq"), size = 2.2*intersection_size_number_scale, vjust = -1,
Expand Down