Skip to content
Discussion options

You must be logged in to vote

I believe this to be an issue with plotly itself as if you use your favourite browser and inspect the figure, you can see the HTML/CSS structure.
You can override with something like:

---
title: "Minimal working example of plotly figure not centering"
format:
  html: 
    include-in-header:
      - text: |
          <style>
            figure > div:has(.plotly-graph-div) {
              display: flex !important;
              justify-content: center !important;
            }

            .plotly-graph-div {
              margin-left: auto !important;
              margin-right: auto !important;
              display: block !important;
            }
          </style>
---

```{python}
# | …

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@meggitt-vibro
Comment options

Answer selected by meggitt-vibro
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
figures plotly themes Related to HTML theming or any other style related issue (like highlight-style)
2 participants