我找到了一个网站scikit-rf
http://scikit-rf.readthedocs.io/en/latest/tutorials/plotting.html
它可以通过以下代码
创建史密斯图ntwk = rf.Network("my data path")
ntwk.plot_s_smith()
然后我想把它嵌入我的python gui。
import sys
from PyQt4 import QtGui,QtCore
import matplotlib
import matplotlib.figure
from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas
from matplotlib.backends.backend_qt4agg import NavigationToolbar2QT as NavigationToolbar
import skrf as rf
import numpy as np
class PrettyWidget(QtGui.QMainWindow):
def __init__(self):
super(PrettyWidget, self).__init__()
self.setGeometry(100,100,1200,700)
self.center()
self.setWindowTitle('NRW')
self.initUI()
def initUI(self):
grid = QtGui.QGridLayout()
self.setLayout(grid)
self.figure = matplotlib.figure.Figure()
self.canvas = FigureCanvas(self.figure)
self.toolbar = NavigationToolbar(self.canvas, self)
grid.addWidget(self.canvas, 3,0,2,12)
def plot1(self):
self.figure.clf()
self.figure.tight_layout()
self.canvas.draw()
if __name__ == '__main__':
app = QtGui.QApplication(sys.argv)
app.aboutToQuit.connect(app.deleteLater)
GUI = PrettyWidget()
GUI.show()
app.exec_()
但我不知道如何在
下面放置或修改代码ntwk = rf.Network("my data path")
ntwk.plot_s_smith()
有人会告诉我你是否有任何iedas?谢谢!
答案 0 :(得分:1)
Network.plot_s_smith有一个ax
关键字可以在现有的 Axes 对象上绘制。所以你可以像这样修改你的绘图函数:
def plot1(self):
self.figure.clf()
ntwk = rf.Network("my data path")
ntwk.plot_s_smith(ax=self.figure.gca())
self.figure.tight_layout()
self.canvas.draw()