Matplotlib plot not showing

Hello,
While learning Keras, I was running some python code in RStudio using exactly the code in: deep-learning-with-python-notebooks/5.2-using-convnets-with-small-datasets.ipynb at master · fchollet/deep-learning-with-python-notebooks · GitHub

Not the first time I come across with this issue, but today it got me annoyed enough :stuck_out_tongue: . The matplotlib plots are not showing. When I execute the following:

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

acc  = history.history['acc']
val  = history.history['val_acc']
loss = history.history['loss']
val_loss = history.history['val_loss']

epochs = range(1,len(acc)+1)

plt.plot(epochs,acc,'bo',label='Training acc')
plt.plot(epochs,val_acc,'bo',label='Validation acc')
plt.title('Training and Validation accuracy')
plt.legend()

plt.figure()

I just get this in the console (and nothing in the plot panel):

[<matplotlib.lines.Line2D object at 0x00000201853C21D0>]
[<matplotlib.lines.Line2D object at 0x00000201853C2550>]
Text(0.5, 1.0, 'Training and Validation accuracy')
<matplotlib.legend.Legend object at 0x0000020184FC9630>
<Figure size 640x480 with 0 Axes>

Thanks,
Pedro

1 Like

I think you have to call plt.show() for the plot to be displayed.

Ref. RStudio IDE Tools for reticulate • reticulate

3 Likes

Thanks Yarnabrina,
That did the job.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.