-
Notifications
You must be signed in to change notification settings - Fork 147
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
setting size of mainbar.y.max #41
Comments
Hello Philipp, the intersection size bar plot is not implemented with coord_cartesian(). The ggplot function for the main bar graph can be found in at the bottom of the MainBar.R file (https://github.com/hms-dbmi/UpSetR/blob/master/R/MainBar.R) |
Hello Jake, Sorry for sending the code snippet as is, but wasn't sure how this is properly done. ##
# if ymax is set by the user, save in a different variable adding the 10% space
if(is.null(ymax) == F){
y_coord <- ymax + 0.1 * ymax
}
# ten_perc creates appropriate space above highest bar so number doesnt get cut off
ten_perc <- ((max(Main_bar_data$freq)) * 0.1)
# currently ymax needs to be calculated in any case, because scale_y_continuous() is used, change?
ymax <- max(Main_bar_data$freq) + ten_perc
# if ymax is not set by the user then y_coord should equal calculated ymax
if(is.null(ymax) == T){
y_coord <- ymax
}
Main_bar_plot <- (ggplot(data = Main_bar_data, aes_string(x = "x", y = "freq"))
+ geom_bar(stat = "identity", width = 0.6,
fill = Main_bar_data$color)
+ scale_x_continuous(limits = c(0,(nrow(Main_bar_data)+1 )), expand = c(0,0),
breaks = NULL)
+ scale_y_continuous(limits = c(0, ymax),
expand = c(c(0,0), c(0,0)))
+ xlab(NULL) + ylab(ylabel) +labs(title = NULL)
+ theme(panel.background = element_rect(fill = "white"),
plot.margin = unit(c(0.5,0.5,0.19,0.5), "lines"), panel.border = element_blank(),
axis.title.y = element_text(vjust = -0.8, size = 8.3), axis.text.y = element_text(vjust=0.3,
size=7 ))
+ coord_cartesian(ylim = c(0, y_coord))) # use coord_cartesian to zoom in on plot
if((show_num == "yes") || (show_num == "Yes")){
Main_bar_plot <- (Main_bar_plot + geom_text(aes_string(label = "freq"), size = 2.2, vjust = -1,
angle = number_angles, colour = Main_bar_data$color))
} |
Hi, thanks so much for the great package!
it seems that mainbar.y.max can not accept values that are less than the size of the largest intersection size bar. If doing so I get the following error: "Error: Aesthetics must be either length 1 or the same as the data (59): fill In addition: Warning message: Removed 4 rows containing missing values (position_stack)."
I was wondering whether you implemented this with coord_cartesian() in ggplot2 or not. If yes I was wondering why I might get this error.
BW
Philipp
The text was updated successfully, but these errors were encountered: