I got the image in html page.
Code-
views.py
import matplotlib.pyplot as plt
from io import BytesIO
import base64
def result(request):
plt.bar(x,h)
plt.xlabel("Personality")
plt.ylabel("Scale")
axes = plt. gca()
axes. xaxis. label. set_size(15)
axes. yaxis. label. set_size(15)
buf = BytesIO()
plt.savefig(buf, format='png', dpi=300)
image_base64 = base64.b64encode(buf.getvalue()).decode('utf-8').replace('\n', '')
buf.close()
return render(request,'result.html',{"image_base64":image_base64})
result.html-
<img src="data:image/png;base64,{{image_base64}}" alt="some text to display to your users when the image does not show correctly" width=500 height=auto />