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; 
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
.histoutputs 9x9 2d array ofmatplotlib.axes._subplots.axessubplotobjects - 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 widthw, heighthofeach graph - then use
layout((n / c), c),figsize=((c * w), (( (n/c) * h ))
- hard code number of columns
- determine number of groups:
- setting x axis limits: axes array
axes = df...loop on axes applyingset_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
Post a Comment