Skip to content
Snippets Groups Projects
Commit df5dbe12 authored by JOSSOUD Olivier's avatar JOSSOUD Olivier
Browse files

Pumpcalib. Linear regression line. (+legend, not really working)

parent f254288d
No related branches found
No related tags found
No related merge requests found
......@@ -176,7 +176,7 @@
<x>10</x>
<y>20</y>
<width>371</width>
<height>31</height>
<height>32</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_4">
......@@ -207,7 +207,7 @@
<rect>
<x>15</x>
<y>70</y>
<width>281</width>
<width>271</width>
<height>161</height>
</rect>
</property>
......@@ -221,10 +221,10 @@
</property>
<property name="geometry">
<rect>
<x>301</x>
<x>291</x>
<y>70</y>
<width>81</width>
<height>23</height>
<width>91</width>
<height>31</height>
</rect>
</property>
<property name="text">
......@@ -459,8 +459,8 @@
<rect>
<x>10</x>
<y>10</y>
<width>111</width>
<height>22</height>
<width>141</width>
<height>31</height>
</rect>
</property>
<item>
......@@ -483,7 +483,7 @@
<property name="geometry">
<rect>
<x>10</x>
<y>40</y>
<y>50</y>
<width>831</width>
<height>431</height>
</rect>
......@@ -508,7 +508,7 @@
<x>0</x>
<y>0</y>
<width>1355</width>
<height>20</height>
<height>26</height>
</rect>
</property>
<widget class="QMenu" name="menuInstrument">
......
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file '..\pyqt\mainwindow.ui'
# Form implementation generated from reading ui file '../pyqt/mainwindow.ui'
#
# Created by: PyQt5 UI code generator 5.11.3
#
......@@ -75,7 +75,7 @@ class Ui_MainWindow(object):
self.explo_groupbox_setups.setGeometry(QtCore.QRect(950, 10, 391, 241))
self.explo_groupbox_setups.setObjectName("explo_groupbox_setups")
self.horizontalLayoutWidget_4 = QtWidgets.QWidget(self.explo_groupbox_setups)
self.horizontalLayoutWidget_4.setGeometry(QtCore.QRect(10, 20, 371, 31))
self.horizontalLayoutWidget_4.setGeometry(QtCore.QRect(10, 20, 371, 32))
self.horizontalLayoutWidget_4.setObjectName("horizontalLayoutWidget_4")
self.horizontalLayout_4 = QtWidgets.QHBoxLayout(self.horizontalLayoutWidget_4)
self.horizontalLayout_4.setContentsMargins(0, 0, 0, 0)
......@@ -91,12 +91,12 @@ class Ui_MainWindow(object):
self.explo_pushbutton_setup_save.setObjectName("explo_pushbutton_setup_save")
self.horizontalLayout_4.addWidget(self.explo_pushbutton_setup_save)
self.explo_listwidget_setup_list = QtWidgets.QListWidget(self.explo_groupbox_setups)
self.explo_listwidget_setup_list.setGeometry(QtCore.QRect(15, 70, 281, 161))
self.explo_listwidget_setup_list.setGeometry(QtCore.QRect(15, 70, 271, 161))
self.explo_listwidget_setup_list.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectRows)
self.explo_listwidget_setup_list.setObjectName("explo_listwidget_setup_list")
self.explo_pushbutton_setup_load = QtWidgets.QPushButton(self.explo_groupbox_setups)
self.explo_pushbutton_setup_load.setEnabled(False)
self.explo_pushbutton_setup_load.setGeometry(QtCore.QRect(301, 70, 81, 23))
self.explo_pushbutton_setup_load.setGeometry(QtCore.QRect(291, 70, 91, 31))
self.explo_pushbutton_setup_load.setObjectName("explo_pushbutton_setup_load")
self.tabWidget.addTab(self.tab_explo, "")
self.tab_conductcalib = QtWidgets.QWidget()
......@@ -178,13 +178,13 @@ class Ui_MainWindow(object):
self.tab_pumpcalib = QtWidgets.QWidget()
self.tab_pumpcalib.setObjectName("tab_pumpcalib")
self.pump_combobox_pump = QtWidgets.QComboBox(self.tab_pumpcalib)
self.pump_combobox_pump.setGeometry(QtCore.QRect(10, 10, 111, 22))
self.pump_combobox_pump.setGeometry(QtCore.QRect(10, 10, 141, 31))
self.pump_combobox_pump.setObjectName("pump_combobox_pump")
self.pump_combobox_pump.addItem("")
self.pump_combobox_pump.addItem("")
self.pump_combobox_pump.addItem("")
self.pump_graphicsview_runs = PlotWidget(self.tab_pumpcalib)
self.pump_graphicsview_runs.setGeometry(QtCore.QRect(10, 40, 831, 431))
self.pump_graphicsview_runs.setGeometry(QtCore.QRect(10, 50, 831, 431))
self.pump_graphicsview_runs.setObjectName("pump_graphicsview_runs")
self.pump_graphicsview_repro = PlotWidget(self.tab_pumpcalib)
self.pump_graphicsview_repro.setGeometry(QtCore.QRect(10, 490, 831, 431))
......@@ -192,7 +192,7 @@ class Ui_MainWindow(object):
self.tabWidget.addTab(self.tab_pumpcalib, "")
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtWidgets.QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 1355, 20))
self.menubar.setGeometry(QtCore.QRect(0, 0, 1355, 26))
self.menubar.setObjectName("menubar")
self.menuInstrument = QtWidgets.QMenu(self.menubar)
self.menuInstrument.setObjectName("menuInstrument")
......
......@@ -14,7 +14,7 @@ from dataprovider.pumpcalibprovider import PumpCalibProvider
from uim.conductcalibuim import ConductCalibUim
from uim.explouim import ExploUim
from uim.pumpcalibim import PumpCalibUim
from uim.pumpcalibuim import PumpCalibUim
########################################################################################################################
# CONFIG
......
import datetime
import re
from math import atan, degrees
import pyqtgraph as pg
from PyQt5.QtWidgets import *
from PyQt5.QtGui import QColor
......@@ -65,19 +66,49 @@ class PumpCalibUim:
self.runs_points_list = []
def __update_runs_plot__(self, runs_df: pd.DataFrame, coef_df: pd.DataFrame) -> None:
# Create the color scale
color_map = pg.ColorMap(pos=[runs_df["calib_id_int"].min(),
runs_df["calib_id_int"].max()],
color=[[0, 0, 255], [0, 255, 0]])
brushes = [pg.mkBrush(color=color) for color in color_map.mapToQColor(runs_df["calib_id_int"])]
runs_points = pg.ScatterPlotItem(runs_df["rpm"],
runs_df["flow"],
size=5,
brush=brushes)
self.plot_item.addItem(runs_points)
# Add legend
# self.plot_item.addLegend((100,60), offset=(70,30))
# self.plot_item.plot([1, 3, 2, 4], pen='r', name='red plot')
# l = pg.LegendItem((100,60), offset=(70,30)) # args are (size, offset)
l = pg.LegendItem() # args are (size, offset)
l.setParentItem(self.plot_item.graphicsItem()) # Note we do NOT call plt.addItem in this case
# Add linear regression line
# self.linear_line = pg.PlotCurveItem()
# plot_item.addItem(self.linear_line)
for row_id, row in coef_df.iterrows():
reg_line = pg.InfiniteLine(pos=QPointF(0, row["intercept"]),
angle=degrees(atan(row["slope"])),
pen=pg.mkPen(color=color_map.mapToQColor(row["calib_id_int"])),
name=row["calib_id_str"])
self.plot_item.addItem(reg_line)
# Add runs points
for calib_id in runs_df["calib_id_int"].unique():
run_df = runs_df[runs_df["calib_id_int"] == calib_id]
# brushes = [pg.mkBrush(color=color) for color in color_map.mapToQColor(runs_df["calib_id_int"])]
run_points = pg.ScatterPlotItem(run_df["rpm"],
run_df["flow"],
size=6,
brush=color_map.mapToQColor(calib_id),
name=run_df["calib_id_str"].unique())
l.addItem(run_points,run_df["calib_id_str"].unique())
self.plot_item.addItem(run_points)
# Add runs text
# for row_id, row in runs_df.iterrows():
# if row_id != 1:
# continue
# run_text = pg.TextItem(text=row["calib_id_str"],
# # color=color_map.mapToQColor(row["calib_id_int"]),
# anchor=QPointF(row["rpm"], row["flow"]))
# # self.plot_item.getViewBox().disableAutoRange()
# self.plot_item.addItem(run_text)
# # self.plot_item.addItem(run_text, ignoreBounds=True)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment