Mplfinance: Adjust the candle width

Created on 27 Jan 2020  路  3Comments  路  Source: matplotlib/mplfinance

Hello,

is there a possibility to adjust the candle width (1, 2, 4 hours etc.)?

regards

question

All 3 comments

You should be able to do this using pandas.DataFrame.resample() before passing the data into mpf.plot(). Let me know if you need more detail.

Additional information here: Resampling Time Series Data with Pandas

Hello Daniel,
tank you, DataFrame.resample() works great! I already coded a loop, but your way is better:

def adjust_candle_width(ticker_frame, sample_time='1D'):
    adj_ticker_frame = ticker_frame.resample(sample_time).agg({
        'Open': 'first',
        'High': 'max',
        'Low': 'min',
        'Close': 'last',
        'Volume': 'sum'
    })
    return adj_ticker_frame
Was this page helpful?
0 / 5 - 0 ratings

Related issues

obahat picture obahat  路  3Comments

tmcguire65 picture tmcguire65  路  6Comments

skfnxh picture skfnxh  路  3Comments

franklee00 picture franklee00  路  4Comments

simonholzapfel picture simonholzapfel  路  5Comments