Thursday 15 September 2011

python - Adding volume overlay in matplotlib -


I conspiracy to plot some financial data using the Matplotlib.finance library and I am trying candlestick 2 part is working fine though `Volume_overlay function is not showing anything on the plot, although the second axis is being correctly scaled.

There is a similar question but it does not solve the problem, just provides a way to create your own Volume Overlay. Get data from # csv data = pandas.read_csv ('dummy_data.csv', header = none, name = ['time', 'value', 'quantity'])

  # csv data. Set_index ('time') # 30 minutes data in the compartment in the random data = data. [[:, ['Value', 'volume']] bars = bars. value. '.' ('30min', how '= ohlc') Volume = Tix. Volume. Properties ('30 min', how-to = 'yoga') # Build figure fig = plt.figure () ax1 = fig.add_subplot (111) # Plant candlestick candles = Candlestick 2 (axis 1, bar ['Open Volume Overlay Add a second axis to ax2 = ax1.twinx (), bars ['off'], bars ['high'], bars ['lower'], width = 1, color = 'g' # plot volume overlay Volume_Warley (AC2, Bar ['Open'], Bars ['Close'], Volume, Color = 'G', Alpha = 0.5) plt.show ()   

Can show me what I remember Is it? Or the volume_overlay function is broken?

edit

data is downloaded from - Notepad ++ And then searched and replaced with "" \ n ".

A lot There is a stupid bug (or maybe strange design options) in it volume_overlay a policlan , but does not add it to the axes. The following should be done: matplotlib.finance import * data = Parse_yahoo_historical (fetch_historical_yahoo ('CKSW', ( 2013,1,1), (2013, 6, 1))

  Ds open, closes, highs, lows, quantity = zip (* data) # Make Fig Fig = Plt.figure () ax1 = fig.add_subplot (111) # Plant candlestick candles = Candlestick 2 (axis 1 opens, closes, highs, lows, width = 1, color = 'g') # Volume Add a second axis to overlay ax2 = ax1.twinx () # Plot Quantity overlay BC = Volume_overlay (axis 2 opens, closes, Volume, Colored = 'G' Alpha = 0.5, width = 1) ax2.add_collection(BC) plt.show () << / code>  

[This is fixed and it will be in 1.3.0 when it ships]

No comments:

Post a Comment