-
Hello, I've been using scikit-rf and it is great for plotting Smith charts! Here's an example: However, I had two questions. Firstly, has anyone got any example code that demonstrates a large Smith chart, with axes with numbers on them, such as this one: The second question is, how can markers be drawn on the output traces? For instance, I might need a marker at 1 GHz on the orange trace, and a marker at 2 GHz on the blue trace. Any help/pointers would be gratefully appreciated. Many thanks. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
import skrf as rf
from matplotlib import pyplot as plt
rf.stylely()
from skrf.data import ring_slot
n = ring_slot.s11
marker_idx = [30, 60, 90]
# prepare figure
fig, axs = plt.subplots(1, 2, figsize=(8, 4))
# nice smith chart
rf.plotting.smith(ax = axs[0], draw_labels = True, ref_imm = 50.0, chart_type = 'z')
n.plot_s_smith(ax = axs[0], linewidth=1.0)
leg1 = axs[0].legend(loc="upper right", fontsize= 6)
# plot markers
col_labels = ['Frequency', 'Real Imag']
row_labels = []
cell_text = []
for i, k in enumerate(marker_idx):
x = n.s.real[k, 0, 0]
y = n.s.imag[k, 0, 0]
f = n.frequency.f_scaled[k]
row_labels.append(f'M{i}')
axs[0].scatter(x, y, marker = 'v', s=20, color='k')
axs[0].annotate(row_labels[-1], (x, y), xytext=(-7, 7), textcoords='offset points', color='k')
cell_text.append([f'{f} {n.frequency.unit}', f'{x:.4f} + {y:.4f}j'])
# plot the table
the_table = axs[1].table(cellText=cell_text,
colWidths=[0.4] * 2,
rowLabels=row_labels,
colLabels=col_labels,
loc='center')
the_table.auto_set_font_size(False)
the_table.set_fontsize(6)
#the_table.scale(1.5, 1.5)
axs[1].axis("off") |
Beta Was this translation helpful? Give feedback.
-
Hello @shabaz123 thank you for your interest in the smith chart. import skrf as rf
from matplotlib import pyplot as plt
import numpy as np
rf.stylely()
from skrf.data import ring_slot
n = ring_slot
marker_idx = [30, 60, 90]
colors = ['g', 'r']
to_plot = [0, 1]
# prepare figure
fig, ax = plt.subplots(1, 1, figsize=(7,8))
background = plt.imread('smithchart.png')
# nice smith chart
# tweak background position
ax.imshow(background, extent=[-1.19, 1.14, -1.13, 1.15])
rf.plotting.smith(ax = ax, draw_labels = True, ref_imm = 1.0, chart_type = 'z')
# plot markers
col_labels = ['Frequency', 'Real Imag']
row_labels = []
cell_text = []
for j in to_plot:
color = colors[j]
n.plot_s_smith(j, j, ax = ax, linewidth=1.0, color=color)
for i, k in enumerate(marker_idx):
x = n.s.real[k, j, j]
y = n.s.imag[k, j, j]
z = f'{n.z.real[k, j, j]:.4f} + {n.z.imag[k, j, j]:.4f}j ohm'
f = n.frequency.f_scaled[k]
row_labels.append(f'M{i}')
ax.scatter(x, y, marker = 'v', s=20, color=color)
ax.annotate(row_labels[-1], (x, y), xytext=(-7, 7), textcoords='offset points', color=color)
cell_text.append([f'{f} {n.frequency.unit}', z])
leg1 = ax.legend(loc="upper right", fontsize= 6)
# plot the table
the_table = ax.table(cellText=cell_text,
colWidths=[0.4] * 2,
rowLabels=row_labels,
colLabels=col_labels,
rowColours=np.repeat(colors, len(marker_idx)),
loc='bottom')
the_table.auto_set_font_size(False)
the_table.set_fontsize(6)
#the_table.scale(1.5, 1.5) |
Beta Was this translation helpful? Give feedback.
-
Hi @mhuser |
Beta Was this translation helpful? Give feedback.
Hello @shabaz123 thank you for your interest in the smith chart.
I do not know a simple way to have interactive markers but you will find below an example with two traces and your background image.