tensor - box plot from a tensor
I'm trying to create a box between two variables probability (y axis) and flowername ( x- axis) .Probability is a tensor. For the flower name, I have to pick the name from a dictionary (flower_dict) where the key is referenced from another tensor, class Index. How do I create box plot ? ANy help is appreciate

print("Probability:", probs)
Probability: tensor([[ 0.9961,  0.0020,  0.0011,  0.0005,  0.0001]], device='cuda:0')

print("Class Index:", classes)
Class Index: tensor([[  21,  3,  45,  34,  27]], device='cuda:0')

print(flower_dict)
{'21': 'fire lily', '3': 'canterbury bells', '45': 'bolero deep blue', '1': 'pink primrose', '34': 'mexican aster', '27': 'prince of wales feathers', '7': 'moon orchid', '16': 'globe-flower', '25': 'grape hyacinth', '26': 'corn poppy', '79': 'toad lily', '39': 'siam tulip', '24': 'red ginger'}


I guess you mean creating a bar plot here (with box-plots you usually depict distributions like for examining features etc.; in the iris flower case for example you might want to examine sepal-length in a box plot). If bar plot is what you want, then you can try the following code:

import numpy as np
import matplotlib.pyplot as plt

y = probs.flatten().numpy()
x = [flower_dict[str(i)] for i in classes.flatten().numpy()]

p1 = plt.bar(x, y, width)

plt.ylabel('Probability')
plt.xticks(ind, x)

plt.show()


Hope this helps!
