fig.align
is not working with R Markdown HTML outputs and plotly and I looking for some help!
Here is a MWE:
---
title: "Untitled"
output: html_document
editor_options:
chunk_output_type: console
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE, fig.align = "center")
library(plotly)
```
```{r}
plot_ly(
x = c("giraffes", "orangutans"),
y = c(20, 14),
name = "SF Zoo",
type = "bar")
```
```{r, fig.align = 'right'}
plot_ly(
x = c("giraffes", "orangutans"),
y = c(20, 14),
name = "SF Zoo",
type = "bar")
```
```{r, fig.align = 'center'}
plot_ly(
x = c("giraffes", "orangutans"),
y = c(20, 14),
name = "SF Zoo",
type = "bar")
```
Unlike normal plots, plotly graphics have a different HTML setup. What you can do is use the shiny package and wrap another div container around each plot:
library(shiny)
div(plot_ly(
x = c("giraffes", "orangutans"),
y = c(20, 14),
name = "SF Zoo",
type = "bar"), align = "right")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With