Neural Networks in Action

Neural Network (3) Classifier and Linear Model

[Graduation project] Design and implementation of convolutional neural network classifier [source code + paper]

Python: Cross-platform serial scanner (with full source code)

Do you know winform, wpf, winui and maui in NET?

Legend Tricks in Python Data Visualization

pyecharts

Python calls the pyserial library to realize automatic control of RS232 commands

port – serial port name (COMn or /dev/ttyUSBn or /dev/ttySn) or None

baudrate (int) – baud rate, such as 9600 or 115200

bytesize – number of data bits, possible parameter values ​​are: FIVEBITS, SIXBITS, SEVENBITS, EIGHTBITS

parity – parity, possible parameter values: PARITY_NONE, PARITY_EVEN, PARITY_ODD
, PARITY_MARK, PARITY_SPACE

stopbits – number of stop bits. Possible values: STOPBITS_ONE, STOPBITS_ONE_POINT_FIVE,
STOPBITS_TWO

timeout (float) – set the maximum time (s) that pyserial will continue to read data

xonxoff (bool) – whether to enable software flow control

rtscts (bool) – Whether to enable hardware (RTS/CTS) flow control

dsrdtr (bool) – Whether to enable hardware (DSR/DTR) flow control

write_timeout (float) – set the longest time for pyserial to write serial data (s)

inter_byte_timeout (float) – inter-byte timeout, if not disabled (disabled by default).

Make a serial assistant | python + pyqt5

Teach you to create a new winform project (the most complete in history)

[PyQt5] How does QThread multi-thread set the slot to receive signals?

PyQt5, PySide2, and PySide6 use QLabel to display pictures, zoom the picture and maintain the aspect ratio.
For relatively large pictures, if the QLabel size is fixed, the picture will not be fully displayed. For relatively small pictures, there may be a blank space around the picture. To do this, the image should be scaled to a suitable size. If it is required that the picture cannot be deformed and aliased, the aspect ratio of the picture should also be maintained.

pixmap = QPixmap("../images/image.jpg").scaled(self.label.size(), aspectMode=Qt.KeepAspectRatio)
self.label.setPixmap(pixmap)
self.label.repaint()

QT designer set background picture stretch version

insert image description here

1. What is PyQtgraph
PyQtGraph is a graphics and user interface library for Python that provides functionality commonly required in engineering and scientific applications. Its main goals are:

    1) 提供用于显示数据(绘图、视频等)的快速交互式图形,以及

     2)提供有助于快速应用程序开发的工具(例如,Qt Designer 中使用的属性树)。

    PyQtGraph 大量使用 Qt GUI 平台(通过 PyQt 或 PySide)获得高性能图形,使用 numpy 进行大量数字运算。特别是,pyqtgraph 使用了 Qt 的 GraphicsView 框架,它本身就是一个功能强大的图形系统;我们为这个框架带来了优化和简化的原语,以最小的努力实现数据可视化。

2. The core functions of pyqtgraph include:
basic data visualization primitives: images, line charts and scatter plots

Fast enough to update video/drawing data in real time

Interactive zoom/pan, average, FFT, SVG/PNG export

Widget for marking/selecting drawing areas

Widgets for marking/selecting image regions of interest and automatically slicing multidimensional image data

A framework for building custom image region-of-interest widgets

A docking system that replaces/supplements Qt's docking system to allow more complex (and more predictable) docking arrangements

ParameterTree widget for rapid prototyping of dynamic interfaces (similar to property trees in Qt Designer and many other applications)

It runs on Linux, Windows and OSX.

3. Why choose PyQtgraph
over matplotlib: For plotting, pyqtgraph is not as complete/mature as matplotlib, but runs much faster. Matplotlib is more geared toward producing publication-quality graphs, while pyqtgraph is intended for use in data acquisition and analysis applications. Matplotlib is more intuitive for matlab programmers; pyqtgraph is more intuitive for python/qt programmers. Matplotlib (as far as I know) doesn't include many of pyqtgraph's features, such as graph interaction, volume rendering, parameter trees, flowcharts, etc.

pyqwt5: About as fast as pyqtgraph, but less complete in plotting capabilities. Image handling in pyqtgraph is much more complete (again, there is no ROI widget in qwt). Also, pyqtgraph is written in pure python, so is more portable than pyqwt, and tends to lag behind pyqt in development (I used pyqwt initially, but found it too cumbersome to depend on it as a dependency in my project). Like matplotlib, pyqwt (as far as I know) does not include many of pyqtgraph's features, such as image interaction, volume rendering, parameter trees, flowcharts, etc. Matplotlib creates graphs with check button legends
for an unlimited number of plots

import numpy as np
import matplotlib.pyplot as plt
from matplotlib.widgets import CheckButtons

t = np.arange(0.0, 2.0, 0.01)
s0 = np.sin(2*np.pi*t)
s1 = np.sin(4*np.pi*t)
s2 = np.sin(6*np.pi*t)

fig, ax = plt.subplots()

def addplotlines(t,s, color, label, visible=True):
    l, = ax.plot(t, s, visible=visible, lw=2, color=color, label=label)
    plt.subplots_adjust(left=0.2)
    return l

lines = []
lines.append(addplotlines(t, s0, 'k', '2 Hz', False))
lines.append(addplotlines(t, s1, 'r', '4 Hz', True))
lines.append(addplotlines(t, s2, 'g', '6 Hz', True))

# Make checkbuttons with all plotted lines with correct visibility
rax = plt.axes([0.05, 0.4, 0.1, 0.15])
labels = [str(line.get_label()) for line in lines]
visibility = [line.get_visible() for line in lines]
check = CheckButtons(rax, labels, visibility)


def func(label):
    index = labels.index(label)
    lines[index].set_visible(not lines[index].get_visible())
    plt.draw()

check.on_clicked(func)

plt.show()

Matplotlib advanced tutorial (2.6) automatic scaling

insert image description here

Guess you like

Origin blog.csdn.net/kunwen123/article/details/131766878