title: R ggplot2 Specify separate color gradients by group
body: <p>I'm trying to make separate color gradients for grouped data that is displayed on the same scatterplot. I've included sample data below. User is unique user IDs, task is unique task IDs, days_completion is the time in days when the task was completed, task_group is the group indicator that the tasks are grouped into, and task_order is the order in which the tasks were made available for users to complete. Each row represents the time that the user completed a specific task. The task_order may not logically follow this organization as it was randomly generated, but it should suffice for demonstration. </p>
  
  <p>The resulting plot would have days_completion of the x axis, user on the y axis, each point from geom_point would represent the time in days that the user completed their task. The tasks groups would each have their own color in a gradient of dark to light by task_order. For example, task group 1 would be dark red at task order == 1 and light red at task order == 7.</p>
  
  <p>Sample code is below:</p>
  
  <pre><code>library(dplyr)
  library(forcats)
  library(ggplot2)
  
  test_data &lt;- tibble(user = rep(seq(1:50), 10) %&gt;% 
                        as_factor(),
                      task = sample(1:10, 500, replace = TRUE) %&gt;% 
                        as_factor(),
                      days_completion = sample(1:500, 500, replace = FALSE),
                      task_group = sample(1:3, 500, replace = TRUE) %&gt;% 
                        as_factor(),
                      task_order = sample(1:7, 500, replace = TRUE, prob = c(rep(.25,3),.2,.2,.1,.1)) %&gt;% 
                        as_factor()) %&gt;% 
    arrange(days_completion)
  
  #Sample plotting approach; does not work
  test_plot &lt;- test_data %&gt;% 
                ggplot(aes(x = days_completion, y = user, color = task)) +
                geom_point() +
                #This seems to be what I need, but I can't figure out how to specify multiple gradients by task_group
                scale_color_gradient()
  </code></pre>
  
  <p>I know I could manually order the factors and map colors with hex codes, but I'd like something that can scale and avoid the manual process. Also, if anyone has any suggestions for how to display this plot other than a scatterplot, I'm open to suggestions. The main idea is to detect patterns in completion time in trends displayed by the color. The trends may not show due to it being randomly generated data, but that's okay.</p>