Dea*_*ris 10 matplotlib python-2.6
目前我试图让自己熟悉matplotlib.pyplot库.在看了一些示例和教程之后,我注意到子图函数也有一些返回值,这些值通常在以后使用.但是,在matplotlib网站上,我无法找到关于究竟返回的内容的任何规范,并且没有一个示例是相同的(尽管它通常似乎是一个ax对象).你们可以给我一些关于返回内容的指示,以及如何使用它.提前致谢!
Ric*_*ren 13
在文档中它表示matplotlib.pyplot.subplots返回一个实例Figure和一个(或单个)Axes数组(数组与否取决于子图的数量).
常用的是:
import matplotlib.pyplot as plt
import numpy as np
f, axes = plt.subplots(1,2) # 1 row containing 2 subplots.
# Plot random points on one subplots.
axes[0].scatter(np.random.randn(10), np.random.randn(10))
# Plot histogram on the other one.
axes[1].hist(np.random.randn(100))
# Adjust the size and layout through the Figure-object.
f.set_size_inches(10, 5)
f.tight_layout()
Run Code Online (Sandbox Code Playgroud)