Skip to content

Instantly share code, notes, and snippets.

@Matjaz-B
Created April 15, 2021 13:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Matjaz-B/fc5d9e396065e4b604edfa47c7c4009f to your computer and use it in GitHub Desktop.
Save Matjaz-B/fc5d9e396065e4b604edfa47c7c4009f to your computer and use it in GitHub Desktop.
Plot multiple s1p plots on one graph
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