python - Altering individual graphs in Pandas hist groupby plot -


i'm plotting frequencies group countries in ipython notebook using:

df['country'].hist(by=df['frequency'], bins=yr_bins) 

but resultant figure badly formatted; badly_formattedhist

things i'd like/like able define:

  • y axis log or not
  • sizing of individual graphs
  • x axis limits
  • auto layout
  • spacing between each individual graph labels don't on lap

things i've realised far:

  • the call .hist outputs 9x9 2d array of matplotlib.axes._subplots.axessubplot objects
  • all of these axessubplotss embedded in single figure

best working case far:

  • for log or not: using keyword log=true
  • sizing of individual graphs , auto layout:

    • determine number of groups: n = len(df.groupby('country')
    • then use combination of keywords layout=(row, column) , figsize(width, height):
      • hard code number of columns c, , desired width w , height h ofeach graph
      • then use layout((n / c), c) , figsize=((c * w), (( (n/c) * h ))
  • setting x axis limits: axes array axes = df... loop on axes applying set_xlim(lim)
       row in axes:            ax in row:                ax.set_xlim(lim) 
  • the spacing turnout of if required do:

    plt.subplots_adjust(wspace=0.5, hspace=1) 

Comments

Popular posts from this blog

java - pagination of xlsx file to XSSFworkbook using apache POI -

Unlimited choices in BASH case statement -

apache - How do I stop my index.php being run twice for every user -