【问题标题】:AttributeError: 'Line2D' object has no property 'ax'AttributeError:“Line2D”对象没有属性“ax”
【发布时间】:2021-05-04 03:04:47
【问题描述】:

代码:

fig, ax = plt.subplots()

错误:

AttributeError: 'Line2D' 对象没有属性 'ax'

【问题讨论】:

  • 那行代码不可能产生你描述的错误。请剪切并粘贴周围的代码。

标签: python matplotlib


【解决方案1】:
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() 轴上绘图。
猜你喜欢
  • 2021-01-20
  • 2021-01-06
  • 1970-01-01
  • 1970-01-01
  • 2012-12-01
  • 2021-04-19
  • 2021-11-22
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多