8import matplotlib.animation
as animation
9import matplotlib.patches
as patches
10import matplotlib.pyplot
as plt
18df = pd.read_csv(
"example-output.txt", sep=
r"\s+", comment=
"#")
30fig, (ax_map, ax_snr) = plt.subplots(1, 2, figsize=(12, 6))
33ax_map.set_xlim(-25, 600)
34ax_map.set_ylim(-25, 1000)
35ax_map.set_xlabel(
"X [m]")
36ax_map.set_ylabel(
"Y [m]")
37ax_map.set_aspect(
"equal")
38tx_circle = patches.Circle((0, 0), 5, color=
"blue", alpha=0.35)
39rx_circle = patches.Circle((0, 0), 5, color=
"red", alpha=0.35)
40ax_map.add_patch(tx_circle)
41ax_map.add_patch(rx_circle)
45ax_snr.set_ylim(-20, 100)
46ax_snr.set_xlabel(
"Time [s]")
47ax_snr.set_ylabel(
"SNR [dB]")
49(snr_line,) = ax_snr.plot([], [],
"k-")
51buildings = pd.read_csv(
"buildings.txt", sep=
r"\s+", comment=
"#", header=
None)
53for idx, row
in buildings.iterrows():
57 rect = patches.Rectangle((x0, y0), width, height, color=
"gray", alpha=0.5)
58 ax_map.add_patch(rect)
59 building_patches.append(rect)
65 tx_circle.set_center((row.iloc[TX_X], row.iloc[TX_Y]))
66 rx_circle.set_center((row.iloc[RX_X], row.iloc[RX_Y]))
67 snr_line.set_data(df.iloc[: frame + 1, TIME], df.iloc[: frame + 1, SNR])
68 ax_map.set_title(f
"Time = {row.iloc[TIME]:.1f} s")
69 return tx_circle, rx_circle, snr_line
73ani = animation.FuncAnimation(fig, update, frames=len(df), interval=0.001, blit=
False)
76ani.save(
"map.gif", writer=
"pillow")
80plt.plot(df.iloc[:, TIME], df.iloc[:, SNR],
"k-")