I have a Rmarkdown document containing some python code chunks using the reticulate
library. The code executes output perfectly; however, how would I cross-reference the generated plots in the text using its label? I am using bookdown::pdf_documents2
etc, and have no issue with inline reference of R chunks using the standard \@ref(fig:my-plot)
.
An MWE would be:
```{python, my-plot}
import matplotlib.pyplot as plt
import numpy as np
x = np.arange(10)
y = np.arange(10)
plt.figure()
plt.plot(x, y)
plt.show()
```
In Figure \@ref(fig:my-plot)
....
I have tried without prepending the chunk type (fig, etc.)
I understand I can save the image to file and include it with knitr
as a subsequent R chunk, but it would be preferable to do it through the python chunk alone.