【发布时间】:2021-05-04 03:04:47
【问题描述】:
代码:
fig, ax = plt.subplots()
错误:
AttributeError: 'Line2D' 对象没有属性 'ax'
【问题讨论】:
-
那行代码不可能产生你描述的错误。请剪切并粘贴周围的代码。
标签: python matplotlib
代码:
fig, ax = plt.subplots()
错误:
AttributeError: 'Line2D' 对象没有属性 'ax'
【问题讨论】:
标签: python matplotlib
plt.figure(figsize=(10, 5))
plt.style.use('seaborn')
fig, ax = plt.subplots()
plt.plot(x,y)
ax.xaxis.set_ticks(x)
【讨论】:
plt.figure() 在这里并没有真正做任何事情。你实际上只是在plt.subplots() 轴上绘图。