highfestiva / finplot

Performant and effortless finance plotting for Python
MIT License
934 stars 187 forks source link

Several embedded finplot windows in one layout #141

Closed gryabov closed 3 years ago

gryabov commented 3 years ago

Hi, thank you for the library.

My question: can I have several emdedded finplot windows into one layout. I have to see 30m and 1min at the same time, so I have to place two finplot widgets into one layout. Separate dataset for each panel.

highfestiva commented 3 years ago

Check out this example.

gryabov commented 3 years ago

For embedded I use:

        fp = finplot.FinWindow(title="chart")
        self.ax = finplot.create_plot_widget(fp, rows=1, init_zoom_periods=100)
        fp.ci.addItem(self.ax, row=0, col=0)
        layout.addWidget(fp, 1, 0, 1, 1)

but self.ax.ax_widget does not exists

self.verticalLayout.addWidget(self.ax.ax_widget)
AttributeError: 'PlotItem' object has no attribute 'ax_widget'
highfestiva commented 3 years ago

FinWindow does not support manual layouting, you need to create a window of your own. See example above.

gryabov commented 3 years ago

Thanks. finplot.set_time_inspector stopped working.

finplot.set_time_inspector(self.update_legend_text, ax=self.ax, when='hover')

Error

   win.proxy_hover = pg.SignalProxy(win.scene().sigMouseMoved, rateLimit=15, slot=partial(_inspect_pos, ax, inspector))
AttributeError: 'NoneType' object has no attribute 'sigMouseMoved'
highfestiva commented 3 years ago

That's because your window does not have a scene() function. That functionality comes from pyqtgraph, but if you want to roll your own window, you might have to build your own time inspector. I'm not familiar with the details myself, so feel free to chuck in a pull request if fixes are needed in the finplot end.