Giter Club home page Giter Club logo

Comments (2)

JakeConway avatar JakeConway commented on May 20, 2024

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)

from upsetr.

pagyeman avatar pagyeman commented on May 20, 2024

Hello Jake,
Not sure whether this is helpful, but below is a slight adaption of your Make_main_bar function that uses coord_cartesian() to change y-axis dimensions of the bar plot (code can probably be optimized, but it worked for me). This will not throw an error, even if the value for mainbar.y.max is smaller than the largest set. This was useful in my special use case.

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))
  }

from upsetr.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.