'How to plot subplot by unit plot function

I have a function to plot a unit plot:

def show_detail(sample):  #sample => sample index
    plt.figure()
    plt.subplot(121)
    plt.title(f"Example of Digit: { str(Y_true[sample])}")
    plt.imshow(X_test[sample],'gray')
    probs = model.predict(X_test)
    plt.subplot(122)
    plt.bar(np.arange(10),probs[sample])
    plt.xticks(np.arange(10), np.arange(10).astype(str))
    plt.show()

and get a result like this:

[enter image description here][1]

The question is how to plot samples in a two-columns figure by the function? like this [enter image description here][2]

Thanks. [1]: https://i.stack.imgur.com/l8tnQ.png [2]: https://i.stack.imgur.com/G6Wvu.png



Sources

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

Source: Stack Overflow

Solution Source