Reputation: 25528
Consider the following code:
---
title: "Untitled"
format: pdf
---
```{python}
#| echo: false
#| fig-align: center
#| fig-width: 1cm
import matplotlib.pyplot as plt
x = [1, 2]
y = [2, 3]
plt.plot(x,y)
```
The parameter fig-width
has no effect whatever the chosen width.
Could someone please help me?
Upvotes: 0
Views: 2056
Reputation: 20087
You can also use set_figwidth
from matplotlib
to control the plot figure sizes generated by matplotlib
.
---
title: "Untitled"
format: pdf
engine: jupyter
---
```{python}
#| echo: false
#| fig-align: center
import matplotlib.pyplot as plt
plot = plt.figure()
plot.set_figwidth(2)
plot.set_figheight(3)
x = [1, 2]
y = [2, 3]
plt.plot(x,y)
```
Try with integer number 2 instead of 2cm
. (It works when with engine: knitr
)
---
title: "Untitled"
format: pdf
engine: knitr
---
```{python}
#| echo: false
#| fig-align: center
#| fig-width: 2
import matplotlib.pyplot as plt
x = [1, 2]
y = [2, 3]
plt.plot(x,y)
```
Upvotes: 1