Overlaying multiple plots

It’s possible to extend a visualization generated by IPKISS and add your own information using matplotlib. The example below demonstrates how to create a figure and reuse it to overlay three different plots.

Example of overlaying multiple plots
import si_fab.all as pdk
import ipkiss3.all as i3
import pylab as plt


trace_template = pdk.M1WireTemplate()
trace_template.Layout(width=10)

# Create the main figure
fig = plt.figure()
plt.title("Example of overlaying multiple plots")

# Create and plot some control points
control_points = [(50, 50), (100, 150)]
cp_plot = plt.scatter(*zip(*control_points), marker="x", s=100, label="control points")

# Add an electrical wire to the figure. show=False since we are still going to add things to our plot.
wire = i3.ConnectElectrical.connect(
    start_port=i3.ElectricalPort(name="in", position=(0, 0), trace_template=trace_template),
    end_port=i3.ElectricalPort(name="out", position=(200, 300), trace_template=trace_template),
    start_angle=0,
    end_angle=180,
    control_points=control_points,
    min_straight=10,
)
wire.get_default_view(i3.LayoutView).visualize(figure=fig, annotate=True, show=False)

# Overlay the figure with arrows indicating the start and end angle
plt.arrow(0, 0, 20, 0, width=2, label="start angle", color="green")
plt.arrow(200, 300, -20, 0, width=2, label="end angle", color="red")

# Finally show everything
plt.legend()
plt.show()