title: Arrange 4 plotly pie graphs in R
body: <p>I have four separate pie graphs all with the same specified color scheme (the code is identical apart from the dataframe). </p>
  
  <p>The colors are designated because I want to combine them in the 4 grid graph with one legend using the same designated colors for each of the 5 groups (ie. when the colors are not designated, the colors are automatically allocated based on the size of the group). </p>
  
  <p>Example Data:</p>
  
  <pre><code># Data
  g = c("D","L","X","A","N","B")
  v = c(49,14,9,7,6,5)
  
  df1 = data.frame(group = g, value = v)
  set.seed(9) # Just for reproductibility
  df2 = data.frame(group = sample(g,size = nrow(df1),replace = F),
                   value = sample(v,size = nrow(df1),replace = F)
                   )
  
  set.seed(8) 
  df3 = data.frame(group = sample(g,size = nrow(df1),replace = F),
                   value = sample(v,size = nrow(df1),replace = F)
  )
  
  set.seed(7)
  df4 = data.frame(group = sample(g,size = nrow(df1),replace = F),
                   value = sample(v,size = nrow(df1),replace = F)
  )
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/VdGYs.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VdGYs.png" alt="piegraph data"></a></p>
  
  <p>The code:</p>
  
  <pre><code>BC &lt;- 
  
         plot_ly(b_c, labels = ~group, values = ~value, marker = list(colors = c(  '#2ca02c',  '#d62728','#9467bd', '#FF7F0E', '#1F77B4')), type = 'pie',textposition = 'outside',textinfo = 'label+percent') %&gt;%
         layout(title = 'b_c',autosize = F, width = 690, height = 690, margin = m,
                xaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE),
                yaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE))
       BC   
  </code></pre>
  
  <p>I have reviewed these posts, but have not been able to determine an answer for combing the plots from these. </p>
  
  <p><a href="https://stackoverflow.com/questions/46013559/subplots-deploying-in-r-plotly?rq=1">Subplots deploying in R Plotly</a></p>
  
  <p><a href="https://stackoverflow.com/questions/47481057/plotting-multiple-pie-charts-in-plotly">Plotting multiple pie charts in plotly</a></p>
  
  <p>I am looking for something similar to ggarrange in ggplot</p>
  
  <p>I have four sets of data, some of which have the same groups (ie. the same row names). For these I would like to use the same color. </p>
  
  <p>I don't really mind about the color scheme (ie. can be any color), but would like to have a unifying color legend for all 4 piegraphs. </p>