Matplotlib subplots vs axes vs axis (singular / plural)

后端 未结 2 739
别跟我提以往
别跟我提以往 2021-02-14 16:36

Can you please clarify some Matplotlib terminology:

  • is the word \"subplots\" (or \"subplot\"?) synonymous to \"axes\"?
  • what are singulars / plurals of \"a
2条回答
  •  梦谈多话
    2021-02-14 16:59

    Axes is the plural of axis. A subplot usually has an x-axis and a y-axis, which together form the two axes of the subplot.

    Let's talk in terms of function/class names:

    Figure.add_subplot or pyplot.subplot return a AxesSubplot object. This in turn contains a XAxis and a YAxis object.

    fig = plt.figure()
    ax = fig.add_subplot(111)
    x = ax.xaxis
    
    print(type(ax))   # matplotlib.axes._subplots.AxesSubplot
    print(type(x))    # matplotlib.axis.XAxis
    

    XAxis is derived from base class Axis. AxesSubplot is derived from SubplotBase and Axes.

提交回复
热议问题