python - 在 Python 上绘制史密斯图
问题描述
我正在尝试使用 matplotlib 和 scikit-rf 在 python 中绘制史密斯图,
我已经在图中绘制了史密斯图,但我需要能够在程序中绘制它以将其可视化为图形。按照我找到的示例,我有一个问题,当我想绘制它时,它的格式不是x,y。
我能做些什么才能画出来?
from PyQt5.QtWidgets import*
from matplotlib.backends.backend_qt5agg import FigureCanvas
from matplotlib.figure import Figure
类 SmithPrueba_graphicsView(QWidget):
def __init__(self, parent = None):
QWidget.__init__(self, parent)
self.canvas = FigureCanvas(Figure())
vertical_layout = QVBoxLayout()
vertical_layout.addWidget(self.canvas)
# vertical_layout = QVBoxLayout()
# vertical_layout.addWidget(self.canvas)
#self.canvas.axes = self.canvas.figure.add_subplot(111)
self.canvas.axes = self.canvas.figure.add_subplot(111)
self.setLayout(vertical_layout)
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtWidgets import*
from PyQt5.uic import loadUi
from matplotlib.backends.backend_qt5agg import (NavigationToolbar2QT as NavigationToolbar)
import PruebaCartaSmith
import numpy as np
import random
import skrf as rf
from skrf.data import ring_slot
from skrf import Network
from skrf import Frequency
import matplotlib.pyplot as plt
import os
class PruebaSmithChart(PruebaCartaSmith.QtWidgets.QMainWindow,PruebaCartaSmith.Ui_MainWindow):
# def __init__(self, parent,design2open):
# super(MatplotlibWidget, self).__init__()
def __init__(self):
QMainWindow.__init__(self)
self.setupUi(self)
self.setWindowTitle("PyQt5 & Matplotlib Example GUI")
self.pushButton_generate_random_signal.clicked.connect(self.update_graph)
self.addToolBar(NavigationToolbar(self.SmithPrueba_graphicsView.canvas, self))
def update_graph(self):
prueba=Network('UserProjects/proyecto3_pro/Datasets/pruebasmithdataset.s2p')
self.SmithPrueba_graphicsView.canvas.axes.clear()
self.SmithPrueba_graphicsView.canvas.axes.plot(prueba.plot_s_smith())
self.SmithPrueba_graphicsView.canvas.axes.set_title('Cosinus - Sinus Signal')
self.SmithPrueba_graphicsView.canvas.draw()
app = PruebaCartaSmith.QtWidgets.QApplication([])
# MainWindow=Ui_MainWindow()
window = PruebaSmithChart()
window.show()
app.exec_()
解决方案
推荐阅读
- c++ - 简单的代码不能用 clang 或 gcc 编译,但它可以用 g++
- python - 如何在 Python 中只写一次标题
- azure - 如何在 azure devops 中运行 docker 容器?
- vagrant - 如何解决 vagrant VM 上的 micok8s 端口转发错误?
- sql - 大于数组的任何元素
- linux - 在 linux 中更改 ldap 用户的主目录
- python-3.x - 为什么我需要使用 'key_event' ?它的作用是什么?
- ldap - ldap/openid 与 FIDO2 连接?
- node.js - 与 Nestjs 断开连接(由于超时错误,insertMany)
- python - 使用 mark.parametrize 装饰器时如何使用补丁装饰器?