I want to show a figure which is plotted by matplotlib
and seaborn
, and the code looks as below:
# plot a figure and then I want to save it into `img_buf` and transform it into `PIL Image` then show it on `output`:
figs = []
for i in range(10):
# code to plot a figure
img_buf = io.BytesIO()
plt.savefig(img_buf, format='png')
figs.append(PIL.Image.open(img_buf))
When I tried to do this, I get below error:
Input should be a valid string [type=string_type, input_value=<PIL.PngImagePlugin.PngIm...0x600 at 0x7F0195C7AC20>, input_type=PngImageFile]