【发布时间】:2017-03-22 10:13:34
【问题描述】:
我正在尝试用如下示例中的折线图覆盖堆积条形图,但只显示了第二个图,无法理解原因。
import pandas as pd
from matplotlib import pyplot as plt
df=pd.DataFrame({'yarding, mobile cable yarder on trailer': {1928: 1.4027824821879459e-20, 1924: 3.4365045943961052e-37, 1925: 6.9939032596152882e-30, 1926: 1.0712940173393567e-25, 1927: 8.6539917152671678e-23},
'yarding and processing, mobile cable yarder on truck': {1928: 1.1679873528237404e-20, 1924: 2.8613089094435456e-37, 1925: 5.8232768671842113e-30, 1926: 8.9198283644271726e-26, 1927: 7.2055027953028907e-23},
'delimbing, with excavator-based processor': {1928: 1.6998969986716558e-20, 1924: 4.1643685881703105e-37, 1925: 8.4752370448040848e-30, 1926: 1.2981979323251926e-25, 1927: 1.0486938381883222e-22}})
df2=pd.Series({1928: 3.0638184091973243e-19, 1924: 7.5056562764093482e-36, 1925: 1.5275356821475311e-28, 1926: 2.3398091372066067e-24, 1927: 1.8901157781841223e-21})
ax=df.plot(kind='bar',stacked=True,legend=False)
df2.plot(kind='line',ax=ax)
plt.show()
【问题讨论】:
-
您看不到条形,因为它的最大值为 4.5 x 10^-20。
-
我曾尝试做 df=df*1e+26 和 df2=df2*1e+26 作为测试,但问题仍然存在。无论如何,如果我分别绘制两个数据框是可以的,问题是它们不重叠
标签: python pandas matplotlib