'caption multiple figures in 1 Rmarkdown chunk

I want to caption all figures generated in Python chunk in R markdown. Currently it is only giving me 1 caption as I can use fig.cap only once in chunk header. How can I do that? The code is below for 2 different dataframes.

`{python Test1-plot,fig.cap="The shear stress evolution"}

import pandas as pd 
import numpy as np
import matplotlib.pyplot as plt

data = pd.read_table("../gb_cyc_csv/T1_gb_cyc.csv",sep=',',decimal='.',low_memory=False,header=0)
X = data[data.keys()[3]]
X = np.array(X)  
TS = data[data.keys()[9]] 
TS = np.array(TS)
plt.plot(X,TS)
plt.show()

data = pd.read_table("../gb_cyc_csv/T3_gb_cyc.csv",sep=',',decimal='.',low_memory=False,header=0)
X = data[data.keys()[3]]
X = np.array(X)  
N = data[data.keys()[15]]
N = np.array(N)
plt.plot(X,N)
plt.show()


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source