Replies: 2 comments
-
Look at |
Beta Was this translation helpful? Give feedback.
0 replies
-
Thank you! For future record, I was able to use the file that highfestiva mentioned (animate.py) to identify the line that does the horiz scrolling. set_x_pos(xmin, xmax, ax=chart_item_here) The only gotcha is the granularity requires a certain amount of data points or it won't zoom at all. Thank you again highfestiva! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello,
I am using finplot to create widgets to plot a stocks price (ochl). When it opens, the full data of the stock is shown on the widget/plot, as expected. I can scroll and zoom the widget manually and it all works.
But what I would really like to have happen is this.:
when I create the plot that instead of seeing the full data, it automatically zooms in to the past years data, not all of the data. This is akin to me manually zooming in a few times and scrolling to the right so instead of looking at 30yrs worth of data, I zoom to the last years worth of data.
Note: I'm not talking about removing items from the dataframe and replotting, as I want the data to still be there and I can manually scroll backwards as well. I just want to zoom in the Xdir automatically at startup instead of me having to manually zoom each plot.
Eventually, I would like to create GUI buttons that allow me to view the past 1yr, 3yr, 5yr, etc.. this is nearly identical to above but with different options and being triggered off a button press via a GUI event rather than at startup. Again, the GUI is easy to create but I don't know how to zoom?
in the finplot code, the zooming is tied in to mouse position, etc... but that isn't applicable in either of the cases above and I don't know how to trigger it externally.
It would appear that these 4 variables inside FinViewBox are the key, but I'm not sure how to get at or use this data from inside my code. This seems to get called internally during a wheelevent, which I don't have so I was going to try and mimic it.
So my questions are:
Although I've looked through the code, perhaps I missed it. Is there a function to zoom in the X direction (time axis)?
If not, I was thinking of adding a new function to finplot to mimic what the wheelevent zoom code is doing but I'm not sure how to get or set the scale variables above. Any ideas on the best way to approach this? I'm not sure how to access the correct plot axs & FinViewBox parameters above. In the mouse wheel zoom, it's triggered off an event (ev) which appears to handle that.
PS. I did search the discussion forum here and there were a few topics regarding zoom but mostly on Y zooming, mouse wheel zoom or replotting after receiving new data. If there is a discussion on X zooming that I missed, sorry, please point me to it.
Thank you!!
Beta Was this translation helpful? Give feedback.
All reactions