References: https://python-graph-gallery.com
Main References:
Seaborn
Zhihu
Tryolabs
Zhihu2
Colab Reference: https://colab.research.google.com/github/jakevdp/PythonDataScienceHandbook/blob/master/notebooks/04.14-Visualization-With-Seaborn.ipynb
Support References:
https://yanwei-liu.medium.com/python-่ณๆ่ฆ่ฆบๅ็ญ่จ-ไบ-ไฝฟ็จseaborn็นชๅ-3adb03407a9
Installation( import )
import matplotlib.pyplot as plt
import seaborn as sns
sns.set()
Let's Start!!
Conclusion:
jointplot
sns.jointplot(x="x", y="y", data=train)
pairplot
sns.pairplot( train )
relplot
sns.relplot( x="x", y="y", data=train
)
regplot
sns.regplot( x="x", y="y", data=train
catplot
sns.catplot( x="x", y="y", data=train)
histplot
sns.histplot( x="x", hue="z", multiple="stack")
kedplot
sns.kdeplot( x="x", hue="z", multiple="stack")
rugplot
sns.rugplot( x )
FacetGrid
โโโโg = sns.FacetGrid( train, row = 'survived', col = 'class')
โโโโg.map( sns.distplot, "age")
โโโโplt.show()
heatmap
imshow
โโโโimport matplotlib.pyplot as plt
โโโโplt.imshow(Sxx)
size:
Invert_x/y axis
It's just like a C# window program for Python( linux/mac ) ?!
References: https://medium.com/bucketing/weekday-1-็ถqt-ๅญธๆpy-9472af78ccce
python3 -V
pip3 install PySide2
Introduction
Widget: Each component is called "Widget"
GUI Rendering
QUILoader
pyside2-uic
pyside2-uic mainwindow.ui > ui_mainwindow.py
ex.
Layout
Slot
from PySide2 import QtCore
โโโโโโโโ@QtCore.Slot()
โโโโโโโโdef exit(self):
โโโโโโโโ self.close()
sleep_btn.clicked.connect(self.exit)
Signal
from PySide2.QtCore import Signal
โโโโโโโโclass MainWindow(QMainWindow):
โโโโโโโโ hello_signal = Signal(str)
โโโโโโโโ@QtCore.Slot(str)
โโโโโโโโdef say_hello(self, msg):
โโโโโโโโ print('Hello ' + msg)
โโโโโโโโself.hello_signal.connect(self.say_hello)
โโโโโโโโself.hello_signal.emit('Pyside2!')
stop at https://medium.com/bucketing/pyside-6-ๅบ็ค็ฉไปถไป็ดน-label-button-edit-e4efa9fb424d
2021/01/14
Label, Button, Edit
ComboBox, RadioButton, CheckButton, SpinBox
ListWidget, TableWidget, TreeWidget
DockWidget, ToolBox, StackWidget
QColor, QcolorDialog, QPalette
StyleSheet, QFont, QFontDialog
QSystemTrayIcon, Frameless, Window, MouseEvent
Qdialog, QMessageBox
QMenu, QAction, ToolTip, StatusTip
QTimer, QCalendar, QDateEdit
QTimeEdit, QLCDNumber, AnalogClock
Logging
Hello World!
โโโโ#!venv/bin/python3
โโโโimport sys
โโโโfrom PySide2 import QtWidgets
โโโโif '__main__' == __name__:
โโโโ app = QtWidgets.QApplication(sys.argv)
โโโโ w = QtWidgets.QMainWindow()
โโโโ w.show()
โโโโ ret = app.exec_()
โโโโ sys.exit(ret)
โโโโ#!venv/bin/python3
โโโโfrom PySide2.QtWidgets import QLabel
โโโโfrom PySide2.QtWidgets import QMainWindow
โโโโfrom PySide2.QtWidgets import QPushButton
โโโโclass MainWindow(QMainWindow):
โโโโ def __init__(self, parent=None):
โโโโ """Main window, holding all user interface including.
โโโโ Args:
โโโโ parent: parent class of main window
โโโโ Returns:
โโโโ None
โโโโ Raises:
โโโโ None
โโโโ """
โโโโ super(MainWindow, self).__init__(parent)
โโโโ self._width = 800
โโโโ self._height = 600
โโโโ self._title = QLabel('PySide2 is Great', self)
โโโโ self._exit_btn = QPushButton('Exit', self)
โโโโ self.setMinimumSize(self._width, self._height)
โโโโimport sys
โโโโfrom PySide2.QtWidgets import QApplication, QMainWindow
โโโโfrom PySide2.QtCore import QFile
โโโโfrom ui_mainwindow import Ui_MainWindow
โโโโclass MainWindow(QMainWindow):
โโโโ def __init__(self):
โโโโ super(MainWindow, self).__init__()
โโโโ self.ui = Ui_MainWindow()
โโโโ self.ui.setupUi(self)
โโโโif __name__ == "__main__":
โโโโ app = QApplication(sys.argv)
โโโโ window = MainWindow()
โโโโ window.show()
โโโโ sys.exit(app.exec_())
โโโโimport sys
โโโโfrom PySide2.QtUiTools import QUiLoader
โโโโfrom PySide2.QtWidgets import QApplication
โโโโfrom PySide2.QtCore import QFile
โโโโif __name__ == "__main__":
โโโโ app = QApplication(sys.argv)
โโโโ ui_file_name = "mainwindow.ui"
โโโโ ui_file = QFile(ui_file_name)
โโโโ if not ui_file.open(QIODevice.ReadOnly):
โโโโ print("Cannot open {}: {}".format(ui_file_name, ui_file.errorString()))
โโโโ sys.exit(-1)
โโโโ loader = QUiLoader()
โโโโ window = loader.load(ui_file)
โโโโ ui_file.close()
โโโโ if not window:
โโโโ print(loader.errorString())
โโโโ sys.exit(-1)
โโโโ window.show()
โโโโ sys.exit(app.exec_())
VBox/HBox Layout
โโโโ#!venv/bin/python3
โโโโfrom PySide2.QtWidgets import QWidget
โโโโfrom PySide2.QtWidgets import QMainWindow
โโโโfrom PySide2.QtWidgets import QPushButton
โโโโfrom PySide2.QtWidgets import QVBoxLayout, QHBoxLayout, QGridLayout, QFormLayout
โโโโclass MainWindow(QMainWindow):
โโโโ def __init__(self, parent=None):
โโโโ """Main window, holding all user interface including.
โโโโ Args:
โโโโ parent: parent class of main window
โโโโ Returns:
โโโโ None
โโโโ Raises:
โโโโ None
โโโโ """
โโโโ super(MainWindow, self).__init__(parent)
โโโโ self._widget = QWidget()
โโโโ self._width = 400
โโโโ self._height = 300
โโโโ self.setFixedSize(self._width, self._height)
โโโโ g_layout = QGridLayout()
โโโโ v_layout = self.build_v_layout()
โโโโ h_layout = self.build_h_layout()
โโโโ g_layout.addItem(v_layout, 0, 0, 2, 1)
โโโโ g_layout.addItem(h_layout, 0, 1, 1, 1)
โโโโ self._widget.setLayout(g_layout)
โโโโ self.setCentralWidget(self._widget)
โโโโ @staticmethod
โโโโ def build_v_layout():
โโโโ hello_btn = QPushButton('Hello')
โโโโ work_btn = QPushButton('Working')
โโโโ play_btn = QPushButton('Playing')
โโโโ sleep_btn = QPushButton('Sleeping')
โโโโ v_layout = QVBoxLayout()
โโโโ v_layout.addWidget(hello_btn)
โโโโ v_layout.addWidget(work_btn)
โโโโ v_layout.addWidget(play_btn)
โโโโ v_layout.addWidget(sleep_btn)
โโโโ return v_layout
โโโโ @staticmethod
โโโโ def build_h_layout():
โโโโ hello_btn = QPushButton('Hello')
โโโโ work_btn = QPushButton('Working')
โโโโ play_btn = QPushButton('Playing')
โโโโ sleep_btn = QPushButton('Sleeping')
โโโโ h_layout = QHBoxLayout()
โโโโ h_layout.addWidget(hello_btn)
โโโโ h_layout.addWidget(work_btn)
โโโโ h_layout.addWidget(play_btn)
โโโโ h_layout.addWidget(sleep_btn)
โโโโ return h_layout
Questions?