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

Will RangeSlider to be added into mplfinance? #584

Open
YiyuJia opened this issue Jan 12, 2023 · 4 comments
Open

Will RangeSlider to be added into mplfinance? #584

YiyuJia opened this issue Jan 12, 2023 · 4 comments
Labels
enhancement New feature or request

Comments

@YiyuJia
Copy link

YiyuJia commented Jan 12, 2023

It will be great if mplfinance can have RangeSlider by default with subplot of stock volume.

@YiyuJia YiyuJia added the enhancement New feature or request label Jan 12, 2023
@DanielGoldfarb
Copy link
Collaborator

DanielGoldfarb commented Jan 13, 2023

@YiyuJia
Yiyu,
As you may be aware, matplotlib (and by extension mplfinance) is coded to work with different "backends." To quote from the matplotlib documentation:


A lot of documentation on the [matplotlib] website and in the mailing lists refers to the "backend" and many new users are confused by this term. Matplotlib targets many different use cases and output formats. Some people use Matplotlib interactively from the Python shell and have plotting windows pop up when they type commands. Some people run Jupyter notebooks and draw inline plots for quick data analysis. Others embed Matplotlib into graphical user interfaces like PyQt or PyGObject to build rich applications. Some people use Matplotlib in batch scripts to generate postscript images from numerical simulations, and still others run web application servers to dynamically serve up graphs.

To support all of these use cases, Matplotlib can target different outputs, and each of these capabilities is called a backend; the "frontend" is the user facing code, i.e., the plotting code, whereas the "backend" does all the hard work behind-the-scenes to make the figure.

There are two types of backends: user interface backends (for use in PyQt/PySide, PyGObject, Tkinter, wxPython, or macOS/Cocoa); also referred to as "interactive backends") and hardcopy backends to make image files (PNG, SVG, PDF, PS; also referred to as "non-interactive backends").


In an effort to keep mplfinance simple I have been reluctant to add code that might differ or depend on which backend the user has chosen to use. In principle I am not opposed to the idea of widgets such as sliders, as long as it can be done in a way that will not require maintaining mplfinance code that has to differ depending on the backend used.

One possibility might be to use matplotlib.widgets which, in theory, already handle every interactive backend. However jupyter notebooks (a very common use-case) may require other package dependecies for matplotlib.widgets to work in jupyter.

What I would be more inclined to do is come up with a way to make it easier to use GUI widgets with mplfinance, rather than actually embed any GUI related code into mplfinance. In other words, presently it is possible to add your own widgets, such as sliders, by gaining access to mplfinance's Axes objects. It just requires a significant amount of coding external to mplfinance. I would like to perhaps come up with some ways to make it easier, that is to come up with ways to do it with less coding.

I am open to suggestions as to how to implement these ideas. I just want to be clear that I do not want to get mplfinance into a situation where, just by way of example, a user is able to specify that they want a range slide for the volume, but then it does not work for other users because those other users have a different backend or gui package installed. One possibility might be to create a new GUI-specific package that is essentially a wrapper around the existing mplfinance package. That way, mplfinance can remain "pure" while the GUI-specific version can provide all the GUI features that some subset of users want.

Any thoughts?

@alexpvpmindustry
Copy link
Contributor

One possibility might be to create a new GUI-specific package that is essentially a wrapper around the existing mplfinance package. That way, mplfinance can remain "pure" while the GUI-specific version can provide all the GUI features that some subset of users want.

i think this is a good approach. the reason I'm exploring this visualisation tool is that the other finance vis tools like plotly is slow/laggy. I suspect its due to its intractability.

pure matplotlib works fast, so does mplfinance. (for me at least)

don't get me wrong, in an ideal world, I would like to have the intractability as well as speed. but for me, speed is the priority.

@Blessvskp
Copy link

Blessvskp commented May 26, 2023

For charts that require display of tens of thousands of data objects, a method to scroll is required. At present, such large data if plotted in mplfinance, there is no easy solution to move the range of chart and as a result, chart displays congested view.

Rather than range sliders, click buttons would be more convenient.

Range display can be in several ways:

  1. Click, hold and drag the chart
  2. Scroll buttons: there should be four scroll buttons: (i) For bringing in a screen screen full of plotted chart of next or previous screen range - left and right (ii) Like video >> << buttons, for jumping to beginning of data range or end of data range.
  3. Last option should be range slide bar.

I hope that this will receive kind attention of master designers!

Dr. Sai

@white-seolpyo
Copy link

Try this package.

It provides a fast, simple, and movable slider.

https://pypi.org/project/seolpyo-mplchart/

seolpyo-mplchart

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants