My head is spinning from trying to get finplot to create an embedded graph for days with no luck. I decided to restart small.
The code that I included works as-is. However, if I change the import to PyQt6 from PyQt5, it stops working.
The application that I am trying to integrate this into is all done in PyQt6. finplot works and displays externally in my PyQt6 attempts, but I cannot use fplt.create_plot_widget while passing self.window() with PyQt6, it seems.
Honestly, I keep running into trouble any time i try to use pyqtgraph. I sidetracked to do something clever with mplfinance, but I'm back to where i was 6 months ago with trying to get anything graph and Qt related to show up in a layout nicely with the other widgets :/
Any help is appreciated. Thank you.
import sys
import finplot as fplt
from PyQt5.QtWidgets import *
import yfinance
class App(QMainWindow):
def __init__(self):
super().__init__()
self.title = 'PyQt5 - QTabWidget'
self.left = 0
self.top = 0
self.width = 600
self.height = 400
self.setWindowTitle(self.title)
self.setGeometry(self.left, self.top, self.width, self.height)
self.menu = self.menuBar()
self.widget = MyGraphWidget(self)
self.setCentralWidget(self.widget)
fplt.show(qt_exec=False)
self.show()
class MyGraphWidget(QWidget):
def __init__(self, parent):
super(QWidget, self).__init__(parent)
self.layout = QVBoxLayout(self)
self.resize(600, 400)
self.label = QLabel("AAPL")
self.df = yfinance.download('AAPL')
self.fplt_widget1, self.fplt_widget2 = fplt.create_plot_widget(self.window(), rows=2)
fplt.candlestick_ochl(self.df[['Open', 'Close', 'High', 'Low']])
self.layout.addWidget(self.label)
self.window().axs = [self.fplt_widget1]
self.layout.addWidget(self.fplt_widget1.ax_widget)
if __name__ == '__main__':
app = QApplication(sys.argv)
ex = App()
sys.exit(app.exec())