python - matplotlib histogram issues - xticks and excess space in charts -


having couple issues plotting subplots in matplotlib:

  1. i can't x-axis tick labels show on top 2 charts. in code below, haven't once specified subplots share x-axis or anything. i've tried plt.setp(ax.get_xticklabels(), visible=true) well, doesn't change lack of x-axis labels 1 bit.

    plt.subplot2grid((6,4), [0,0], 2, 2) ax = firstperiod.megaball.plot(kind='hist', bins = 25) plt.setp(ax.get_xticklabels(), visible=true)  plt.xticks(range(0,26,5), range(0,26,5), rotation="horizontal") plt.title('megaball distrib \'96 - \'99') plt.ylabel("# of draws", fontsize = 10) 

i've noticed if plot top left histogram, x-axis ticks show up, disappear plot more.

enter image description here

i've tried adjusting tight_layout well, plt.tight_layout(w_pad = 2, h_pad = 2), doesn't show x-axis tick values.

  1. subplot seems leave space in of charts on right hand side. how rid of space , use whole x-axis histogram?

here whole thing looks is.

enter image description here

why of x-axis ticks automatically showing up, , not? , why charts have space? isn't issue when made bar chart instead of histogram... (notice i've tried adjusting hspace , wspace in subplot_adjust well).

fig = plt.figure() fig.suptitle('distribution of megaball draws', fontsize=20)  plt.subplot2grid((6,4), [0,0], 2, 2) ax = firstperiod.megaball.plot(kind='hist', bins = 25) plt.setp(ax.get_xticklabels(), visible=true)  plt.xticks(range(0,26,5), range(0,26,5), rotation="horizontal") plt.title('megaball distrib \'96 - \'99') plt.ylabel("# of draws", fontsize = 10)  plt.subplot2grid((6,4), [0,2], 2, 2) secondperiod.megaball.plot(kind='hist', bins = 36) plt.xticks(range(0,36,5), range(0,41,5), rotation="horizontal") plt.title('megaball distrib \'99 - \'02') plt.ylabel("# of draws", fontsize = 10)  plt.subplot2grid((6,4), [2,0], 2, 2) thirdperiod.megaball.plot(kind='hist', bins = 52) plt.xticks(range(0,55,5), range(0,55,5), rotation="horizontal") plt.title('megaball distrib \'02 - \'05') plt.ylabel("# of draws", fontsize = 10)  plt.subplot2grid((6,4), [2,2], 2, 2) fourthperiod.megaball.plot(kind='hist', bins = 46) plt.xticks(range(0,50,5), range(0,50,5),rotation="horizontal") plt.title('megaball distrib \'05 - \'13') plt.ylabel("# of draws", fontsize = 10)  plt.subplot2grid((6,4), [4,1], 2, 2) fifthperiod.megaball.plot(kind='hist', bins = 15) plt.xticks(rotation="horizontal") plt.title('megaball distrib \'13 - ') plt.ylabel("# of draws", fontsize = 10)  plt.tight_layout(w_pad = 2, h_pad = 2) plt.subplots_adjust(top = 0.8, wspace = 0.75, hspace = 2.5) plt.savefig("megaball_distribs.png") plt.show() 

thanks in advance , guys, killing me.

you can adjust font size bizarrely named fontsize parameter.

plt.title('megaball distrib \'96-99', fontsize = 12) 

Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -