如何缩小Matplotlib图中的边距

1.第一种方法

	import matplotlib.pyplot as plt
	import numpy as np
	pic = np.arange(1000).reshape((50,20))
	plt.imshow(pic)
	plt.savefig('margin.png', bbox_inches='tight')

2.第二种方法

	import matplotlib.pyplot as plt
	import numpy as np
	x = np.linspace(0, 1, 20); y = np.sin(xs)
	fig = plt.figure()
	axes = fig.add_subplot(1,1,1)
	axes.plot(x, y)
	fig.tight_layout()
	fig.savefig('margin.png')

你可能感兴趣的:(笔记,python)