Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The use of returnfig=True creates multiple figures when using ipywidgets #673

Open
thinkrapido opened this issue Jun 1, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@thinkrapido
Copy link

Describe the bug
If you provide returnfig=True or use your own axes, updating the ipywidgets produces additional plots.

To Reproduce
this example uses 15 min klines, but that doesn't matter.

@interact(
        start_pos = widgets.FloatSlider(value=0, max=len(df.index) - 1 - 7 * 96, min=0, step=1),
        length    = widgets.FloatSlider(value=7 * 96, max=7 * 96, min=96, step=96),
        
        )
def plot_func(start_pos, length):
    start_pos, length = int(start_pos), int(length)
    ldf = df.iloc[start_pos:start_pos + length]
    print(ldf.index[0], ' - ', ldf.index[-1])
    mpf.plot(ldf, style='yahoo', figsize=(20,5), returnfig=True)
    #print([ str(ax) for ax in axlist])

Expected behavior
When using ipywidgets and updateing the slider, the reloading of the plot_func produces an additional figure each time you update the widget. This shouldn't be. When your don't use returnfig (or don't add ax and volume by your own figure) this behaviour does not accure.

jupyter lab
mplfinance 0.12.10b0

Screenshots
image

@thinkrapido thinkrapido added the bug Something isn't working label Jun 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant