kmod_max <- function(a,b){
 if( b>a & a>=0 & b>=0 & a<=1 & b<=1) {
  library(ggplot2)  
    ggplot(data.frame(x = 0), aes(x)) + 
      coord_cartesian(expand = FALSE, xlim = c(0, 1.05), ylim = c(0, 2.05)) +
      labs(title = "X :  maximum van 2 unif op [ 0 , 1 ]", subtitle = "f(x) = 2x  voor 0 ≤ x ≤ 1 ",   x = "x-waarde", y ="dichtheidsfunctie") +
      scale_x_continuous(breaks = seq(0, 1, by=0.1)) +
      scale_y_continuous(breaks = seq(0, 2, by=0.25)) +
      theme(plot.title = element_text(size = 15, hjust=0.5, vjust = 2.5),
        plot.subtitle = element_text(size = 15,hjust=0.5, ),
        axis.title.x = element_text(hjust = 0.5),
        axis.title.y = element_text(vjust = 0.5) ,
        aspect.ratio = 1 ) +
      geom_segment(aes(x=a, y=0, xend=b, yend=0),color = "red", linewidth = 2) +
      annotate(geom ="polygon", x= c(a,b,b,a), y= c(0,0,2*b,2*a), fill="blue", alpha=0.1) +
      annotate("text", x = 0.30, y = 1.75, label = paste("GEGEVEN \ninterval van a tot b met \na =",  as.character(round(a, 3)), " en  b =", as.character(round(b, 3))) ,  size = 4.5, color = "red") + 
      annotate("text", x = 0.30, y = 1.25, label = "GEVRAAGD \nkans in interval = \noppervlakte",  size = 4.5, color = "blue") +
      annotate("text", x = 0.30, y = 0.95, label = paste("[=", as.character(round((b-a)*(b+a),4)), "]" ),  size = 4.5, color = "grey30") +      
      geom_segment(aes(x = 0, y = 0, xend = 1, yend = 2))  
 }else{
    cat("controleer of de getallen die \nje hebt ingevuld voldoen aan \n∙ 0 ≤ a ≤ 1 \n∙ 0 ≤ b ≤ 1 \n∙ en bovendien a < b ") }
}