Skip to content

Having subfigures side-by-side in a 2 column fashion. #1762

Answered by choldgraf
atharvaaalok asked this question in Q&A
Discussion options

You must be logged in to vote

I believe that you could accomplish this with the {grid} directive, and two {grid-item} directives inside of it. You could do this with {code-cell} directives to run the code in-line, or you could use {embed} functionality to attach labels to image outputs, then embed them in the grid with {figure} directives.

For example, the following MyST:


## Generate figures

```{code-cell}
:label: fig1
import numpy as np
import pandas as pd
_ = pd.DataFrame(np.random.randn(100, 2)).plot()
```

```{code-cell}
:label: fig2
_ = pd.DataFrame(np.random.randn(100, 2)).plot()
```

## Display as grid

:::::{grid} 2
::::{grid-item}
:::{figure} #fig1
Caption for the first figure.
:::
::::
::::{grid-item}
:::{…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@atharvaaalok
Comment options

Answer selected by atharvaaalok
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants