Matplotlib,从大熊猫数据帧绘制条形图上的多个单独hline

时间:2016-03-21 00:18:03

标签: python pandas matplotlib plot

我有一个简单的pandas数据框和如下图:

import pandas as pd
import matplotlib.pyplot
import numpy as np

test_df_1 = pd.DataFrame(np.random.random_integers(100, size=(10,2)), columns = ['COL_A', 'COL_B'], index=list('abcdefghij'))
test_df_1.plot(kind='bar')

这导致以下情节:

enter image description here

然后我有另一个数据帧:

test_df_2 = pd.DataFrame(np.random.random_integers(100, size=(10,2)), columns = ['COL_A', 'COL_B'], index=list('abcdefghij'))

与我的第一个数据框尺寸相同。我希望将顶部绘制为简单的水平线,如下面的模拟:

enter image description here

我如何实现这一目标?我知道axhline但我不知道如何在这个例子中应用它来实现我想要的目标。

1 个答案:

答案 0 :(得分:2)

我无法想出更好的方法,但您可以从/Users/jess/IBM/Anywhere/MaximoAnywhere/build.xml:127: The following error occurred while executing this line: /Users/jess/IBM/Anywhere/MaximoAnywhere/anywhere-platform-installer.xml:641: The following error occurred while executing this line: /Users/jess/IBM/Anywhere/MaximoAnywhere/anywhere-platform-installer.xml:568: src '/Users/jess/IBM/Anywhere/MaximoAnywhere/build/managed/plugins/iphone/anywhere-plugins-ios.zip' doesn't exist. 获取条形图的信息:

ax.patches

这是输出:

enter image description here