title: Plotly Warning: RColorBrewer::brewer.pal(N, "Set2") :
body: <p>I am working to replicate the plotly density plot example <a href="https://plotly.com/r/line-charts/" rel="nofollow noreferrer">here</a> in R. The code used on the example page is</p>
  <pre><code>library(plotly)
  dens &lt;- with(diamonds, tapply(price, INDEX = cut, density))
  df &lt;- data.frame(
    x = unlist(lapply(dens, &quot;[[&quot;, &quot;x&quot;)),
    y = unlist(lapply(dens, &quot;[[&quot;, &quot;y&quot;)),
    cut = rep(names(dens), each = length(dens[[1]]$x))
  )
  fig &lt;- plot_ly(df, x = ~x, y = ~y, color = ~cut) 
  fig &lt;- fig %&gt;% add_lines()
  fig
  </code></pre>
  <p>Of course this works just fine and a quick preview of the data is</p>
  <pre><code>&gt; str(df)
  'data.frame':   2560 obs. of  3 variables:
   $ x  : num  -1115 -1073 -1032 -991 -949 ...
   $ y  : num  6.74e-08 9.02e-08 1.20e-07 1.57e-07 2.06e-07 ...
   $ cut: chr  &quot;Fair&quot; &quot;Fair&quot; &quot;Fair&quot; &quot;Fair&quot; ...
  </code></pre>
  <p>Now, with my own data (see dput() below for reproducing), the plot is created, but yields a warning</p>
  <pre><code>fig &lt;- plot_ly(df2, x = ~theta, y = ~values, color = ~ind)
  fig &lt;- fig %&gt;% add_lines()
  fig
  Warning messages:
  1: In RColorBrewer::brewer.pal(N, &quot;Set2&quot;) :
    minimal value for n is 3, returning requested palette with 3 different levels
  
  2: In RColorBrewer::brewer.pal(N, &quot;Set2&quot;) :
    minimal value for n is 3, returning requested palette with 3 different levels
  </code></pre>
  <p>The structure of my data are</p>
  <pre><code>&gt; str(df2)
  'data.frame':   34 obs. of  3 variables:
   $ values: num  0.0585 0.1003 0.1672 0.2672 0.4018 ...
   $ ind   : chr  &quot;X1&quot; &quot;X1&quot; &quot;X1&quot; &quot;X1&quot; ...
   $ theta : num  -4 -3.5 -3 -2.5 -2 -1.5 -1 -0.5 0 0.5 ...
  </code></pre>
  <p>The <a href="https://cran.r-project.org/web/packages/RColorBrewer/RColorBrewer.pdf" rel="nofollow noreferrer">documentation</a> on page 3 does specifically state that &quot;...a warning if a palette you asked for exists but not with as many different levels as you asked for.&quot; My data in this case have fewer than 3 in <code>ind</code>.</p>
  <p>However, what I cannot find now is if there is a palette I can set for &lt; 3. I'd rather not supress or just ignore the warning. Any advice for resolution?</p>
  <p>Thanks. Data for reproducing are below.</p>
  <pre><code>&gt; dput(df2)
  structure(list(values = c(0.0584990041577079, 0.100254537023576, 
  0.167189618781583, 0.267205773945374, 0.401760675391809, 0.55864009227321, 
  0.712171241231567, 0.836160108570042, 0.918694081341489, 0.964460695673611, 
  0.986034362720271, 0.994936330930512, 0.998262836587041, 0.999424735793067, 
  0.999813543824513, 0.999940322471119, 0.999981037752802, 0.000454891425316739, 
  0.00138118245593599, 0.0040618318346699, 0.0113553955978209, 
  0.0294536830165663, 0.0690401859334859, 0.143049939374408, 0.258712591235403, 
  0.407910135546857, 0.566494475339215, 0.707280909084666, 0.81478103878707, 
  0.888097594376448, 0.934397771015761, 0.962244935056505, 0.978507400496616, 
  0.987842047415269), ind = c(&quot;X1&quot;, &quot;X1&quot;, &quot;X1&quot;, &quot;X1&quot;, &quot;X1&quot;, &quot;X1&quot;, 
  &quot;X1&quot;, &quot;X1&quot;, &quot;X1&quot;, &quot;X1&quot;, &quot;X1&quot;, &quot;X1&quot;, &quot;X1&quot;, &quot;X1&quot;, &quot;X1&quot;, &quot;X1&quot;, &quot;X1&quot;, 
  &quot;X2&quot;, &quot;X2&quot;, &quot;X2&quot;, &quot;X2&quot;, &quot;X2&quot;, &quot;X2&quot;, &quot;X2&quot;, &quot;X2&quot;, &quot;X2&quot;, &quot;X2&quot;, &quot;X2&quot;, 
  &quot;X2&quot;, &quot;X2&quot;, &quot;X2&quot;, &quot;X2&quot;, &quot;X2&quot;, &quot;X2&quot;), theta = c(-4, -3.5, -3, 
  -2.5, -2, -1.5, -1, -0.5, 0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 
  -4, -3.5, -3, -2.5, -2, -1.5, -1, -0.5, 0, 0.5, 1, 1.5, 2, 2.5, 
  3, 3.5, 4)), row.names = c(401L, 451L, 501L, 551L, 601L, 651L, 
  701L, 751L, 801L, 851L, 901L, 951L, 1001L, 1051L, 1101L, 1151L, 
  1201L, 2002L, 2052L, 2102L, 2152L, 2202L, 2252L, 2302L, 2352L, 
  2402L, 2452L, 2502L, 2552L, 2602L, 2652L, 2702L, 2752L, 2802L
  ), class = &quot;data.frame&quot;)
  </code></pre>