I am soooo very close to finally finishing my convolutional neural network project, but I'm having a difficult time trying to display a figure that shows the top k classification probabilities for a given new traffic sign image. I want to display the scatter plot of the probabilities on the left and the associated image on the right. Here is the function I have defined:
def plot_probability_per_class(probabilities, classes, image):
figure = plt.figure()
figure.subplots_adjust(right=1.5, hspace=0.5)
subplot = figure.add_subplot(1,2,1)
subplot.set_title('Probability per class')
plt.plot(classes, probabilities, 'ro')
plt.ylabel('Probability')
plt.xlabel('Class ID')
subplot = figure.add_subplot(1,2,2)
subplot.set_title('Image')
plt.imshow(image)
plt.show()
Below is an example of the figure that is generated:
And while I'm asking, would someone be able to show me how to place a legend to the right of (or maybe below) the scatterplot to show description of class IDs. Something like the following:
- = Speed limit (20km/h)
- = Speed limit (30km/h)
- = Speed limit (50km/h)
- = Speed limit (60km/h)
- = Speed limit (70km/h)
- = Speed limit (80km/h)
- = End of speed limit (80km/h)
- = Speed limit (100km/h)
- = Speed limit (120km/h)
- = No passing
- = No passing for vehicles over 3.5 metric tons
I'm very new to Matplotlib and I'm finding the API docs difficult to read. Any help would be appreciated.