1

I have a DataFrame df

    A           B
H   
8   0.899160    1
9   41.659693   7
10  336.414450  20
11  8.442857    3
12  0.848837    1
13  3.298130    2
14  3.447251    2
15  7.667236    3
17  0.831579    1
16  0.000000    0

I want to plot 2 histograms on one plot, so H - is the x axis and A with B - y axis. Whatever i try, e.g.:

x = delivered['A']
y = delivered['B']
fig = plt.figure()
ax = fig.add_subplot(111)
x.plot(kind='hist', ax=ax)
y.plot(kind='hist', ax=ax, color='red')

or

p = df.plot(kind='hist', x=['H'])

plots histograms with B as an x-axis. But i need my H{8,9,10,11,12,13,14,15,16,17} to be the x axis!

jrjc
  • 21,103
  • 9
  • 64
  • 78
Ladenkov Vladislav
  • 1,247
  • 2
  • 21
  • 45
  • 1
    You want histogram or barplot ? – jrjc Mar 28 '17 at 18:13
  • why not using matplotlib : http://stackoverflow.com/questions/35878064/plot-two-histograms-on-the-same-graph-and-have-their-columns-sum-to-100 or http://stackoverflow.com/questions/6871201/plot-two-histograms-at-the-same-time-with-matplotlib – Dadep Mar 28 '17 at 18:14
  • @jrjc thank you, that is my mistake. Should i delete the question, or maybe you post an answer and I accept it? – Ladenkov Vladislav Mar 28 '17 at 18:57
  • @LadenkovVladislav You can answer your own question! – jrjc Mar 28 '17 at 19:13

1 Answers1

0

As @jrjc said, the problem was in that i've chosen the wrong type of graph!. As i had already counted the charecteristics for each observation, "bar" graph is needed. "hist" graph is suitable for cases, when i have plenty of rows for each observation.

Ladenkov Vladislav
  • 1,247
  • 2
  • 21
  • 45