【发布时间】:2017-01-18 21:19:32
【问题描述】:
我想我在 matplotlib 的工作流程中遗漏了一些东西......我正在尝试创建一个自定义大小的图形,添加一些东西,然后添加第二个轴:
#temp graph
import matplotlib.pyplot as plt
plt.cla()
plt.clf()
plt.close()
df = r
fig = plt.figure(figsize=(14,6))
ax = fig.add_subplot()
#r is a dataframe filled with a bunch of data
myplot = r[r.index<=100]["TOTAL DATA"].apply(lambda x:x/1000).plot(kind='bar')
ax2 = ax.twinx()
plt.show()
这给了我以下错误:
AttributeError Traceback(最近调用 最后)在() 13 14 ---> 15 ax2 = ax.twinx() 16 17 plt.show()
AttributeError: 'NoneType' 对象没有属性 'twinx'
有什么想法吗?谢谢!
【问题讨论】:
标签: python matplotlib