Titles and axis limits to all subplots with pandas and matplotlib

Viewed 130

I'm trying to print a 3x4 grid of histograms from a dictionary of dataframes. I want to set all of the histograms using the same x and y limits and give all the graphs unique titles. Code below prints all the histograms but the x and y lims and title only appear on the last graph.

nrows = 3
ncols = 4   
count = 0
fig, ax = plt.subplots(nrows,ncols)
for i in ax:
    for axis in i:
        dl[count].hist(['hundreds'], bins=ten_bin, ax=axis)
        plt.title(files[count]+' hundreds')
        plt.xlim([0,9])
        plt.ylim([0,250])
        count+=1

Where dl is the dictionary of data frames and the files list is name of the CSV where the df derives from. Thanks in advance.

0 Answers
Related