0

I've got the following Pandas dataframes:

>>> df
                     Qual_B  temp_B  relhum_B  Qual_F  temp_F  relhum_F
Date                                                                   
1948-01-01 01:00:00       5    -6.0        96     NaN     NaN       NaN
1948-01-01 02:00:00       5    -5.3        97     NaN     NaN       NaN
1948-01-01 03:00:00       5    -4.5        98     NaN     3.5       NaN
1948-01-01 04:00:00       5    -4.3        98     NaN     3.7       NaN
1948-01-01 05:00:00       5    -4.0        99     NaN     NaN       NaN

>>> test
                    Qual_B temp_B relhum_B Qual_F temp_F relhum_F
Date                                                             
1948-01-01 01:00:00   True   True     True  False  False    False
1948-01-01 02:00:00   True   True     True  False  False    False
1948-01-01 03:00:00   True   True     True  False   True    False
1948-01-01 04:00:00   True   True     True  False   True    False
1948-01-01 05:00:00   True   True     True  False  False    False

which represents data availability (I have created test with test = pandas.notnull(df)). I want a plot like this or a stacked barplot with time on the x-axis and the columns on the y axis and I have tried the following:

fig= plt.figure()
ax = fig.add_subplot(111)
ax.imshow(test.values, aspect='auto', cmap=plt.cm.gray, interpolation='nearest')

but it doesn't do anything, even though the type of the array is exactly the same as in the example above (both numpy.ndarray). The try to plot the original dataframe with

test.div(test, axis=0).T.plot(kind = 'barh', stacked=True, legend=False, color='b', edgecolor='none')

seems to be correct for the values, that are always present, but not for those that are partly present. Can anyone help?

Community
  • 1
  • 1
user3017048
  • 2,711
  • 3
  • 22
  • 32
  • Assuming you are using ipython, are you starting up with the pylab inline option? (ipython --pylab inline) – Liam Foley Mar 02 '15 at 07:53
  • I have tried both the inline option as well as `%pylab wx`. Using the standard spyder console, it produces the same result. – user3017048 Mar 02 '15 at 08:21

0 Answers0