Python中的 Matplotlib.pyplot.axes()
Pyplot是matplotlib的另一个模块,它使用户能够将 MATLAB 集成到Python环境中,从而提供类似 MATLAB 的界面,并使Python具有可视化的交互性。
Matplotlib.pyplot.axes()
pyplot.axes
是 matplotlib 库的一个函数,可将轴添加到当前图形并使其成为当前轴。它的输出取决于使用的参数。
Syntax: matplotlib.pyplot.axes(*args, **kwargs)
Parameters:
*args: It may include either None(nothing) or 4 tuples of float type
- none: It gives a new full window axes
- 4 tuples: It takes 4 tuples as list i.e [left bottom width height] and gives a window of these dimensions as axes.
**kwargs: There are several keyword arguments(kwargs) used as parameters to pyplot.axes(), most common include facecolor, gid, in_layout, label, position, xlim, ylim, etc.
示例 1:
# importing matplot library along
# with necessary modules
import matplotlib.pyplot as plt
# providing values to x and y
x = [8, 5, 11, 13, 16, 23]
y = [14, 8, 21, 7, 12, 15]
# to plot x and y
plt.plot(x, y)
# to generate the full window axes
plt.axes()
输出:
示例 2:
# importing matplot library along
# with necessary modules
import matplotlib.pyplot as plt
# providing values to x and y
x = [8, 5, 11, 13, 16, 23]
y = [14, 8, 21, 7, 12, 15]
# to plot x and y
#plt.plot(x, y)
# to generate window of custom
# dimensions [left, bottom, width,
# height] along with the facecolor
plt.axes([0, 2.0, 2.0, 2.0], facecolor = 'black')
输出: