ashim
ashim

Reputation: 25560

How to reduce size of a plot, keeping numbers axis the same?

I made a histogram plot with matplotlib, but the histogram occupies all space on the plot, I would like to add more space around. How can I scale down the histogram, but keep number on the axis the same size?

Upvotes: 1

Views: 87

Answers (1)

Olga Botvinnik
Olga Botvinnik

Reputation: 1644

Could you change the xlimits? try:

fig, ax = plt.subplots(1)
ax.hist(data)

vmin = data.min().min()
vmax = data.max().max()
data_range = vmax - vmin
scale_factor = 0.1
xmin = vmin - scale_factor*vmax
xmax = vmax + scale_factor*vmax
ax.set_xlim(xmin, xmax)

Upvotes: 1

Related Questions