matplotlib - How to adjust the distance between y-axis label in python -
i have code make chart following below:
%pylab inline import numpy np import matplotlib import matplotlib.pyplot plt matplotlib.font_manager import fontproperties matplotlib.use('tkagg') plt.style.use('ggplot') dataframe.t.plot(kind='barh', stacked=true) plt.xticks(np.arange(0, 1.1, 0.1), [str(x) x in np.arange(0, 1.1, 0.1)]) plt.xlim([0, 1]) plt.xlabel("pecentage of interets") plt.ylabel("users") plt.legend(loc=9, bbox_to_anchor=(0.5, -0.2), ncol=7) plt.savefig('personint.jpg', format='eps', dpi=1000, bbox_inches='tight')
the results of code this:
in here, want ask how can adjust distance between y-axis label in code, such space between user1
, user2
, because distance each user in chart close each other.
you need add more vertical space figure, try changing figure size @ beginning of code with:
plt.rcparams["figure.figsize"] = (8, 10)
the vertical space can change dynamically number of y-axis labels.
# labels = ["user1", "user2", ...] plt.rcparams["figure.figsize"] = (8, 6 * len(labels) / 10)
just change division denominator adjust amount of space want give.
Comments
Post a Comment