4/12/2012

pylab - adjust the graph region, make x-axis ticks formatted

1. adjusting the margin of graph region

pylab.gcf().subplots_adjust(bottom=0.2)


2. x-axis ticks formatting
(ref: http://stackoverflow.com/questions/3677368/matplotlib-format-axis-offset-values-to-whole-numbers-or-specific-number )

from matplotlib.ticker import ScalarFormatter, FormatStrFormatter


# Plot the data...
fig = plt.figure()
ax = fig.add_subplot(111)

# Force the y-axis ticks to use 1e-9 as a base exponent
ax.yaxis.set_major_formatter(FixedOrderFormatter(-9))

# Make the x-axis ticks formatted to 0 decimal places
ax.xaxis.set_major_formatter(FormatStrFormatter('%0.0f'))

댓글 없음: