
  # -------------------------------------------------------------------------------------------------------------------------  #
  #  -----------------------------------------------------------------------------------------------------------------------   #
  #                                                                                                                            #
  #           File Name              :  gg_shapes.r                                                                            #
  #           Last Updated Funclist  :  19 Feb 2015,  1:05 PM (Thursday)                                                       #
  #                                                                                                                            #
  #           Author Name            :  Rick Saporta                                                                           #
  #           Author Email           :  RickSaporta@gmail.com                                                                  #
  #           Author URL             :  www.github.com/rsaporta                                                                #
  #                                                                                                                            #
  #           Packages Called        :  NA                                                                                     #
  #           Packages Used via NS   :  NA                                                                                     #
  #                                                                                                                            #
  #  -----------------------------------------------------------------------------------------------------------------------   #
  #                                                                                                                            #
  #   ggShowShapes       ( rows=15, cols=15, minShape=1, verbose=TRUE )                                                        #
  #   ggShowLineTypes    (  )                                                                                                  #
  #                                                                                                                            #
  #                                                                                                                            #
  #                                                     <END FUNCS>                                                            #
  #  -----------------------------------------------------------------------------------------------------------------------   #
  # -------------------------------------------------------------------------------------------------------------------------  #


ggShowShapes <- function(rows=15, cols=15, minShape=1, verbose=TRUE)  {
  
  SHAPES <- data.table(CJ(x=seq(cols), y=seq(rows))[order(y, x)])
  SHAPES[, shape :=factor(seq(x), labels=seq(x) + minShape - 1)]

    
  if (verbose)
    cat("GNERALLY GOOD CHOICES: \n\n\t  choosing <- c(c(3, 4, 8, 15, 16, 17, 18),    c(38, 36, 37, 35))\n\n")

  ggplot(SHAPES, aes(x=x)) + 
   geom_text(aes(y=y-0.15, label=shape), size=2, alpha=.65, valign=.5, color="#555555") +
   geom_point(aes(y=y+0.15, shape=shape, size=2)) + 
   scale_shape_manual(values=SHAPES$shape) + 
   nolegend()
}


ggShowLineTypes <- function() {
  lines <- 1:14
  if (max(lines) %% 2 != 0)
    lines <- c(lines, lines + 1)
  DT <- data.table(linetype=factor(lines), y = -lines)[, list(x=1:10), keyby=list(linetype, y)][, y := y + c(-.3, .15)]
  DT[x > 3 & x < 8, y := mean(y) , by=linetype]
  P  <- ggplot() + geom_line(data=DT, aes(x=x, y=y, linetype=linetype))
  P  +  
    geom_text(data=DT[x %in% c(2, 8)], aes(x=x, y=y, label=linetype), color="white", fontface="bold", size=7.2) + 
    geom_text(data=DT[x %in% c(2, 8)][, x := x + rnorm(x, 0, .005)][, y := y + rnorm(y, 0, .005)], aes(x=x, y=y, label=linetype), color="white", fontface="bold", size=7.2) + 
    geom_text(data=DT[x %in% c(2, 8)], aes(x=x, y=y, label=linetype), color="dark blue", size=6.8) + 
    labs(title="Linetypes Examples", x="", y="") + 
    scale_x_continuous(breaks = NULL) + scale_y_continuous(breaks = NULL)
}
