From fbfabfd4e6d113ec7f0cf38f8dcd67bf15515de2 Mon Sep 17 00:00:00 2001 From: kpatel427 Date: Tue, 23 Jul 2019 16:00:09 -0400 Subject: [PATCH] scatter dotSize param --- 02_Body.R | 6 ++++++ app.R | 6 ++++-- plots/01_Plots-Scatter.R | 10 +++++----- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/02_Body.R b/02_Body.R index 3338a98..26807d1 100644 --- a/02_Body.R +++ b/02_Body.R @@ -8,6 +8,7 @@ library(ggplot2) library(shinycssloaders) library(shinyWidgets) + body <- dashboardBody( includeCSS("template.css"), shinyjs::useShinyjs(), @@ -57,6 +58,7 @@ body <- dashboardBody( ) ), + div(class="output_box", style="width:150%;", #tabBox(status="info","Plot Output", withSpinner(plotOutput('basic_barplot',height = '600px'),color = '#3c8dbc'),value = 'basic_barplot') tabBox( height = '663px',title = @@ -64,6 +66,7 @@ body <- dashboardBody( tags$h3("Set parameters"), #selectInput(inputId = 'xcol', label = 'X Variable', choices = names(iris)), selectInput(inputId = 'colorby', label = 'Color by', choices = c('None')), + #selectInput(inputId = 'selectTheme', label = 'Choose Theme', choices = c(theme_bw(), theme_classic()), selected = theme_bw()), sliderInput(inputId = 'axisFont', label = 'Font Size', value = 10, min = 1, max = 50), radioGroupButtons( inputId = "legendPosition", @@ -81,6 +84,9 @@ body <- dashboardBody( conditionalPanel(condition = "input.radioPlot == 'Bar'", selectInput(inputId = 'test1', label = 'Barplot specific Input', choices = c('None')) ), + conditionalPanel(condition = "input.radioPlot == 'Scatter'", + sliderInput(inputId = 'dotSize', label = 'Dot Size', value = 2, min = 1, max = 20) + ), #selectInput(inputId = 'ycol', label = 'Y Variable', choices = names(iris), selected = names(iris)[[2]]), #sliderInput(inputId = 'clusters', label = 'Cluster count', value = 3, min = 1, max = 9), circle = TRUE, status = "danger", icon = icon("gear"), width = "300px", diff --git a/app.R b/app.R index 458a630..3eb98c9 100644 --- a/app.R +++ b/app.R @@ -124,7 +124,8 @@ shinyApp( "Bar" = bar_plot(data = dt,x=input$selectX,y=input$selectY, colorby = input$colorby, fontSize = input$axisFont, legendPos = input$legendPosition)$plot, "Scatter" = scatter_plot(data = dt,x=input$selectX,y=input$selectY, colorby = input$colorby, - fontSize = input$axisFont, legendPos = input$legendPosition)$plot, + fontSize = input$axisFont, legendPos = input$legendPosition, + dotSize = input$dotSize)$plot, "Line" = line_plot(data = dt,x=input$selectX,y=input$selectY, colorby = input$colorby, fontSize = input$axisFont, legendPos = input$legendPosition)$plot ) @@ -142,7 +143,8 @@ shinyApp( "Bar" = bar_plot(data = dt,x=input$selectX,y=input$selectY, colorby = input$colorby, fontSize = input$axisFont, legendPos = input$legendPosition)$code, "Scatter" = scatter_plot(data = dt,x=input$selectX,y=input$selectY, colorby = input$colorby, - fontSize = input$axisFont, legendPos = input$legendPosition)$code, + fontSize = input$axisFont, legendPos = input$legendPosition, + dotSize = input$dotSize)$code, "Line" = line_plot(data = dt,x=input$selectX,y=input$selectY, colorby = input$colorby, fontSize = input$axisFont, legendPos = input$legendPosition)$code ) diff --git a/plots/01_Plots-Scatter.R b/plots/01_Plots-Scatter.R index 991ad70..22a6dc4 100644 --- a/plots/01_Plots-Scatter.R +++ b/plots/01_Plots-Scatter.R @@ -2,16 +2,16 @@ #1.1 PLOTS CODE: Scatter Plot--------------------- -scatter_plot <- function(data=dt,x=NULL,y=NULL, colorby, fontSize, legendPos) { +scatter_plot <- function(data=dt,x=NULL,y=NULL, colorby, fontSize, legendPos, dotSize) { if(colorby == 'None'){ p <- ggplot(data, aes_string(x,y)) + - geom_point() + + geom_point(size = dotSize) + theme(axis.text = element_text(size = fontSize), axis.title.x = element_text(size = fontSize), axis.title.y = element_text(size = fontSize)) code <- paste0('ggplot(data, aes(',x,',',y,')) + - geom_point() + + geom_point(size = ',dotSize,') + theme(axis.text = element_text(size = ', fontSize,'), axis.title.x = element_text(size = ', fontSize,'), axis.title.y = element_text(size = ', fontSize,'))') @@ -21,14 +21,14 @@ scatter_plot <- function(data=dt,x=NULL,y=NULL, colorby, fontSize, legendPos) { return(ls) } else{ p <- ggplot(data, aes_string(x,y, color = colorby)) + - geom_point() + + geom_point(size = dotSize) + theme(axis.text = element_text(size = fontSize), axis.title.x = element_text(size = fontSize), axis.title.y = element_text(size = fontSize), legend.position = legendPos) code <- paste0('ggplot(data, aes(',x,',',y, ',' ,'color = ', colorby, ')) + - geom_point() + + geom_point(size = ',dotSize,') + theme(axis.text = element_text(size = ', fontSize,'), axis.title.x = element_text(size = ', fontSize,'), axis.title.y = element_text(size = ', fontSize,'),