Matplotlib plt.xlabel() vs ax.set_xlabel()

后端 未结 1 1340
粉色の甜心
粉色の甜心 2021-01-15 23:45

I am using some code that uses the singleton-version of matplotlib in Python, i.e. it has calls like

plt.figure()
...
plt.xlabel(\"abc\")

1条回答
  •  一整个雨季
    2021-01-16 00:21

    Matplotlib had the pyplot interface, and then later developed the object-oriented interface, as described in the documentation (https://matplotlib.org/3.2.1/tutorials/introductory/lifecycle.html).

    The latter is now preferred, so use fig, ax = plt.subplots and then use the setter method on ax.

    0 讨论(0)
提交回复
热议问题