Created
April 15, 2021 13:30
-
-
Save Matjaz-B/fc5d9e396065e4b604edfa47c7c4009f to your computer and use it in GitHub Desktop.
Plot multiple s1p plots on one graph
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib.pyplot as plt | |
import matplotlib.patches as patches | |
import skrf as rf | |
def plot_s1p(title, path, files): | |
fig, (ax) = plt.subplots(1,1, figsize=(20,10)) | |
out = "" | |
for f in files: | |
net = rf.Network(path+f) | |
net.frequency.unit = "mhz" | |
net.plot_s_db(0, 0, label = f) | |
out += "File: {} S11@868MHz: {:.03f}\r\n".format(f, net['868MHz'].s_db[0,0,0]) | |
ax.add_patch(patches.Rectangle([867e6, -50], 2e6, 50, facecolor='red', alpha=0.5)) | |
ax.grid(b=True, which='both', axis='both') | |
ax.set_title(title) | |
plt.legend() | |
fig.canvas.draw() | |
fig.tight_layout() | |
fig.show() | |
print(out) | |
plot_s1p("device1", "C:\\pathy\\path\\", ["file1.s1p", "file2.s1p", "file3.s1p"]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment