Thank you very much for your reply. My codes are like this:

import matplotlib.pyplot as plt
fig,ax=plt.subplots()
ax.step(recall,precision,color=‘r’,alpha=0.99,where=‘post’)
ax.fill_between(recall, precision, alpha=0.2, color=‘b’, step=‘post’)
plt.xlabel(‘Recall’)
plt.ylabel(‘Precision’)
plt.ylim([0.0, 1.05])
plt.xlim([0.0, 1.0])
plt.title(‘2-class Precision-Recall curve: AP={0:0.2f}’.format(
    average_precision))
writer.add_figure(‘epoch_pr’,fig,epoch)
plt.close(fig)

I used the method of add_figure to save and view the pr curve.