python - How do I make grid axes invisible for a pandas dataframe hist()? -
here want do, histogram plots of columns of dataframe without grid axes. below code works, preferably i'd more elegant solution (such passing argument hist)
%matplotlib inline import numpy np import pandas pd import matplotlib.pyplot plt x = np.asarray([50]*25+[30]*10) x2 = np.asarray([90]*10+[20]*25) x3 = np.asarray([10]*15+[70]*20) df = pd.dataframe(np.vstack([x, x2, x3]).t) def plot_hists(df, nbins=10, figsize=(8, 8), disable_axis_labels = true): plt.close('all') grid_of_ax_hists = df.hist(bins=nbins, figsize=figsize) if disable_axis_labels: row in grid_of_ax_hists: ax in row: ax.xaxis.set_visible(false) ax.yaxis.set_visible(false) plt.show() df.hist() plt.subplots() plot_hists(df, nbins=10, figsize=(8, 8), disable_axis_labels = true)
even thread kinda old, i'd add working solution because i've had same issue.
at least in pandas 0.18
df.hist() takes possible plotting keywords pandas.dataframe.plot
df.hist(grid=false)
works easily.. , there no need of dealing matplotlib axes.
Comments
Post a Comment