I need to create two graphs (subplots, synchronous) and set the dimensions as follows:
- the upper graph is 75% of the output area
- and the lower graph is 25% of the height of the output area.
Something like this sketch.
One chart is easy to create (code below). But to add the second subplot - it does not work. I tried to add it through QVBoxLayout() but also failed.
I found an example of what is needed, How to create Subplot using QCharts? but it is not written in Python (which causes trouble when trying to translate to Python). Here https://doc.qt.io/qt-5/qchart.html#chartType-prop is also not there, and also it is not in Python.
How to add a subplot and with the indication of the sizes (in pixels or in%)?
from random import uniform
from PyQt5.QtWidgets import QApplication, QMainWindow
import sys
from PyQt5.QtChart import QChart, QChartView, QLineSeries
class Window(QMainWindow):
def __init__(self):
super().__init__()
self.setGeometry(100, 100, 680, 500)
self.create_linechart()
self.show()
def create_linechart(self):
series = QLineSeries(self)
for i in range(100):
series.append(i, uniform(0, 10))
chart = QChart()
chart.addSeries(series)
chart.createDefaultAxes()
chartview = QChartView(chart)
self.setCentralWidget(chartview)
App = QApplication(sys.argv)
window = Window()
sys.exit(App.exec_())