I have the following framework:
symbol DAL MS QQQ SPY TLT XLE
symbol
DAL NaN NaN NaN NaN NaN NaN
MS 0.560979 NaN NaN NaN NaN NaN
QQQ 0.621045 0.789771 NaN NaN NaN NaN
SPY -0.576444 -0.843485 -0.953304 NaN NaN NaN
TLT 0.186840 0.421957 0.333320 -0.347808 NaN NaN
XLE 0.115093 0.578970 0.559711 -0.701126 0.38047 NaN
Then I add and order the data frame and build the result as a barcode as follows:
dfstacked = corr_df.stack().order()
dfstacked.plot(kind='bar')
symbol symbol
SPY QQQ -0.953304
MS -0.843485
XLE SPY -0.701126
SPY DAL -0.576444
TLT SPY -0.347808
XLE DAL 0.115093
TLT DAL 0.186840
QQQ 0.333320
XLE TLT 0.380470
TLT MS 0.421957
XLE QQQ 0.559711
MS DAL 0.560979
XLE MS 0.578970
QQQ DAL 0.621045
MS 0.789771

What I'm trying to do now (without success) is not to build it like a barcher, but instead build it by filling in the area below and above zero. I assume I should use fill_between, similar to these examples: link :
ax.fill_between(dfstacked.index, 0, dfstacked.values, where = dfstacked.values > 0, interpolate=True)
ax.fill_between(dfstacked.index, dfstacked.values, 0, where = dfstacked.values < 0, interpolate=True)
I get an error: TypeError: ufunc 'isfinite' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
source
share