title: Plotly as png in knitr/rmarkdown
body: <p>The following Rmarkdown renders the plotly 3D graph in HTML, but not in PDF.</p>
  
  <pre><code>Testing plotly
  
  ```{r}
  library(plotly)
  p &lt;- plot_ly(data=iris, x=~Sepal.Length, y=~Sepal.Width, z=~Petal.Length, 
               color=~Species, symbols=c(0,1), type="scatter3d", mode="markers")
  p
  ```
  </code></pre>
  
  <p>A snapshot of the graph appears as follows:</p>
  
  <p><a href="https://i.stack.imgur.com/Ltg2D.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Ltg2D.png" alt="enter image description here"></a></p>
  
  <p>According to the <a href="https://plot.ly/r/knitr/" rel="noreferrer">plotly help page</a>:</p>
  
  <blockquote>
    <p>If you are using rmarkdown with HTML output, printing a plotly object in a code chunk will result in an interactive HTML graph. <strong><em>When using rmarkdown with non-HTML output, printing a plotly object will result in a png screenshot of the graph.</em></strong></p>
  </blockquote>
  
  <p>Is there a way to render the plotly graph in a PDF?</p>
  
  <p><em>Note:</em> The error from <code>rmarkdown::render()</code> is:</p>
  
  <pre><code>Error: Functions that produce HTML output found in document targeting latex output.
  Please change the output type of this document to HTML. Alternatively, you can allow
  HTML output in non-HTML formats by adding this option to the YAML front-matter of
  your rmarkdown file:
  
    always_allow_html: yes
  
  Note however that the HTML output will not be visible in non-HTML formats.
  </code></pre>