Skip to content Skip to sidebar Skip to footer

Adjusting Axis In Matplotlib

When creating my graph using Matplotlib, I have coded it to automatically size the axis as follows: plt.axis([(int(yearofreleaselist[oldestfilm])-1), (int(yearofreleaselist[0]))+1,

Solution 1:

You can disable the offset (see documentation)

import numpy as np
import pylab as pl

years = np.arange(2011,2016,1)
profit = np.random.random(years.size)

pl.figure()
ax=pl.subplot(121)
pl.scatter(years, profit)
ax=pl.subplot(122)
pl.scatter(years, profit)
ax.get_xaxis().get_major_formatter().set_useOffset(False)

enter image description here

Or, to set it for all figures/axes:

import matplotlib as mpl
mpl.rcParams['axes.formatter.useoffset'] = False

Post a Comment for "Adjusting Axis In Matplotlib"