title: How can I fill my density chart with 2 factors in with shiny
body: <p>In my first panel, I have plot where I enter data by clicking or double clinking depending on the situation. If it's one click it categorized as a shot and if it's a double click it is categorized as a goal.</p>
  <p>Simultaneously, on another Tab, I am creating a heat map of all of those shots. However, in my heat map (produced in my code in output$chart) I would like to have two different colours on the same heat map. One colour representing the shots and the other one representing the goal.</p>
  <p>Thank you for your help</p>
  <pre><code>library(shiny)
  library(ggplot2)
  
  ui &lt;- fluidPage(
    titlePanel(&quot;Hockey&quot;),
    tags$img(height = 100, width = 100,
             src = &quot;Logo.png&quot;),
    sidebarPanel(
      textInput(inputId = &quot;date&quot;,
                label = &quot;Date&quot;, 
                value = &quot;yyyy/mm/dd&quot;),
      textInput(inputId = &quot;team&quot;,
                label = &quot;Team Name&quot;, 
                value = &quot;Team Name&quot;),
      selectInput(&quot;shot&quot;, &quot;shot type:&quot;,
                  list(`Shot Type` = list(&quot;wrist shot&quot;, &quot;slap shot&quot;, &quot;snap shot&quot;, &quot;backhand&quot;, &quot;tap in&quot;, &quot;deflection&quot;, &quot;one timer&quot;, &quot;wrap around&quot;))),
      actionButton(&quot;reset&quot;, &quot;Clear&quot;)),
    mainPanel(tabsetPanel(
      tabPanel(&quot;Track&quot;, plotOutput(outputId = &quot;hockeyplot&quot;, click = &quot;plot_click&quot;, dblclick = &quot;plot_dblclick&quot;)),
      tabPanel(&quot;Chart&quot;, plotOutput(outputId = &quot;chart&quot;)),
     
  
  server &lt;- function(input, output){
    
    rv &lt;- reactiveValues(
      df = data.frame(
        x = numeric(),
        y = numeric(),
        Date = as.Date(character()),
        Team = character(),
        ShotType = character(),
        Type = factor()
      )
    )
    
    output$hockeyplot = renderPlot({ 
      ggplot(rv$df,
             aes(x = x, y = y)) + coord_flip() + lims(x = c(0, 100), y = c(42.5, -42.5)) + geom_blank + geom_point( aes(colour = factor(Type)), size = 5 ) + theme(legend.position = &quot;none&quot;)})
    
    
     observeEvent(input$plot_click, {
      rv$df &lt;- rbind(rv$df, data.frame(
        x = input$plot_click$y,
        y = input$plot_click$x,
        Date = input$date, 
        Team = input$team, 
        ShotType = input$shot, 
        Type = &quot;Shot&quot;))
    })
    
    observeEvent(input$plot_dblclick, {
      rv$df &lt;- rbind(rv$df, data.frame(
        x = input$plot_dblclick$y,
        y = input$plot_dblclick$x,
        Date = input$date, 
        Team = input$team,  
        ShotType = input$shot, 
        Type = &quot;Goal&quot;))
    })
    
    observeEvent(input$reset,{
      rv$df &lt;- rv$df[-nrow(rv$df),]
    })
    
  
    
    output$chart = renderPlot({
      ggplot(rv$df, aes(x = x, y = y)) +
        coord_flip()+
        lims(x = c(0, 100), y = c(42.5, -42.5)) +
        geom_blank+
        theme(legend.position = &quot;none&quot;) +
        stat_density_2d(aes(fill = &quot;shot&quot;), geom = 'polygon', alpha = 0.4) 
    })
  
  </code></pre>