Closed degloff closed 3 years ago
create_plot_widget()
, but not using the standard layout..update_data()
in particular, or the api in general.Thanks for the reply. I see what I can do.
There is another catch with update_data, I tried to use the stepMode to plot lines like this:
line1: pg.PlotDataItem = plt.plot(x, y, pen='g', symbol='x', symbolPen='g', symbolBrush=0.2, name='green', stepMode=True)
The catch is that 'len(x) == len(y)+1` is required. Imagine that the x is time, then the last (x,y) is prolonged horizontal till "now". The current setup of update_data does not allow me to do that.
Any ideas?
BTW, it would be helpful to understand your rational of update_data better, if you can explain a bit more it would be very helpful.
If you have an additional data point on your y-axis it requires a time to be apart of a time series. And to plot it too. Otherwise at what time should it go?
The rationale of update_data()
is unfortunately missing. I built it organically/ad hoc, and haven't looked back still. It's pretty slow, highly complicated and already with a large portion of logic to get Qt to re-render it. But the thing that tells me it could be a lot better is that it's always clunky to use. You always have to loop and if-not-created-then-else-update, which is ugly.
If we do not have an additional point we may just duplicate the last x value. Need to check your code how that could be added.
That would just add two datapoints at the same point in time, i.e. two candles on a single X-position. This belongs in user space, not in the lib.
No, that does not work as the data setup enforces same length of x and y as you pull it from the PandasDataSource. I tried that already.
I went through the update_data path and it is indeed grown a bit organically. Hard to see from the code what is a feature and what is needed and what can be simplified.
For bullet number three, you can now use the set_x_pos() function in the API to move the viewport. See the example.
I've thought about your first bullet, and I'm pretty satisfied with keeping it the way it currently is. I.e. plotting only a volume profile zooms/pans on that, but if used in combination with higher-resolution data (candles), it falls into background (standalone). That should have answered all of your questions.
First thanks a lot for this library, it is very useful for me.
I cooked up a real time plot example using cryptofeed pulling orderbook data, following the bitmex example in this repo.
The problems I face are:
Here is the code so you can try around. Happy to contribute it to the samples.