0

I am trying to prepare a histogram with matplotlib. Below you can see my data and my chart.

import pandas as pd
import numpy as np
pd.set_option('max_columns', None)
import matplotlib.pyplot as plt
import matplotlib as mpl

data = {
         'type_sale': ['g_1','g_2','g_3','g_4','g_5','g_6','g_7','g_8','g_9','g_10'],
         'open':[70,20,24,80,20,20,60,20,20,20],
        
        }

df = pd.DataFrame(data, columns = ['type_sale',
                                   'open',
                                   ])

df.hist(bins=20, color ='red')
df.text(0.05, -0.02, '*) Source: Some institution')
plt.show()

enter image description here

So below this bar chart on the left side, I want to add the text '*) Source: Some institution'. I tried but nothing is happen. So can anybody help me how to solve this problem?

silent_hunter
  • 2,224
  • 1
  • 12
  • 30

1 Answers1

1

matplotlib can be used to make chart.

By adding below line can add text to your chart by using matplotlib

plt.figtext(0.5,0.01, "Text under the Plot", ha="center", va="center", 
fontsize=18, bbox={"facecolor":"orange", "alpha":0.5})

Hope this helps. Thanks

y051
  • 184
  • 5