title: Customizing text (text size, text color, text angle) in Plotly for R
body: <p>I'm working on making a donut chart/open pie chart in Plotly. Because of help from this question, <a href="https://stackoverflow.com/questions/56530842/open-pie-chart-donut-chart-in-r-using-plotly-with-count-and-percentage/56531266?noredirect=1#comment99647452_56531266">Open Pie Chart/Donut Chart in R using Plotly with count and percentage</a>, I was able to get fairly far with my plot. However, now I need help customizing the text size, angle, and color.</p>
  
  <p>Here's the dataset:</p>
  
  <pre><code>library(dplyr)
  testfile &lt;- tibble(personID = 1:10,
                     status = c("bad", "good", "bad", "bad", "bad", "bad", "bad", "bad", "bad", "good"),
                     department = c("sales", "sales", "marketing", "sales", "marketing", "management", "management", "sales", "sales", "sales"))
  </code></pre>
  
  <p>Here's the code to make the plot thus far. It has the count and percentage for each status, and in the center, it has the percentage of "good" status individuals.</p>
  
  <pre><code>library(plotly)
  
  plot &lt;- plot_ly(values, labels = ~status, values = ~count, text = ~count, color = I("white")) %&gt;%
    add_pie(hole = 0.6) %&gt;%
    layout(title = "Ratio of Good to Bad",  showlegend = F, position = "topcenter", 
           xaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = TRUE),
           yaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = TRUE))
  
  plot &lt;- layout(p, annotations=list(text=paste(good$count / sum(values$count) * 100, "%", sep=""), "showarrow"=F))
  plot
  </code></pre>
  
  <p>This code yields these two plots. Surprisingly, it looks the first way when I click "zoom" on R Studio, but it looks the second (very wrong) way when I click export and open the PNG file.</p>
  
  <p>Zoomed plot (mostly correct)
  <a href="https://i.stack.imgur.com/KsLTn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KsLTn.png" alt="enter image description here"></a></p>
  
  <p>Exported plot (looks very different than how it should...)
  <a href="https://i.stack.imgur.com/cnLJs.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cnLJs.png" alt="enter image description here"></a></p>
  
  <p>This zoomed in plot is <em>exactly</em> what I want except for three issues:</p>
  
  <ol>
  <li><p>I want the center text (20%) to be larger. I've tried p &lt;- layout(p, annotations=list(text=paste(good$count / sum(values$count) * 100, "%", sep=""), "showarrow"=F, size = 25)) but that did nothing.</p></li>
  <li><p>I want both of the labels (2 20% and 8 80%) to be white, not just the 8 80%. I thought color = I("white") would do the trick, but the output is the same as when I don't specify the color at all.</p></li>
  <li><p>I want the labels to be horizontal instead of curving and for them to fit within the bars.</p></li>
  </ol>
  
  <p>Optional: Why does it look different when it is exported vs zoomed in? I need it to look like the zoomed in version. Also, is there also an easy way to get it to say n = 2 instead of just 2?</p>
  
  <p>Thank you!</p>
  
  <p>EDIT: This code makes the labels horizontal, but they are too small. When I add size = 15 or any number, it always makes the font the same large size but no longer horizontal. This also fixes the issue where the export and zoom are inconsistent. It also fixes the center text size. I just need the labels to both be white, larger in size, and horizontal.</p>
  
  <pre><code>plot &lt;- plot_ly(values, labels = ~status, values = ~count, text = ~count) %&gt;%
    add_pie(hole = 0.6) %&gt;%
    layout(title = "Ratio of Good to Bad",  showlegend = F, position = "topcenter", 
           xaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = TRUE),
           yaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = TRUE),
           annotations=list(text=paste(good$count / sum(values$count) * 100, "%", sep=""), "showarrow"=F, font=list(size = 40)))
  plot
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/fdA98.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fdA98.jpg" alt="enter image description here"></a></p>