From 54c2a104abc8eead69ffaf537031ec4bd012d2a0 Mon Sep 17 00:00:00 2001 From: "Travis F. Collins" Date: Mon, 12 Feb 2024 17:44:20 -0700 Subject: [PATCH] Add Time UI secondary axis Signed-off-by: Travis F. Collins --- examples/ad9081_jesd_eye_diagram.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/examples/ad9081_jesd_eye_diagram.py b/examples/ad9081_jesd_eye_diagram.py index da36d2d5f..0ce1800ee 100644 --- a/examples/ad9081_jesd_eye_diagram.py +++ b/examples/ad9081_jesd_eye_diagram.py @@ -14,6 +14,7 @@ fig = plt.figure() eye_data_per_lane = dev._jesd.get_eye_data() + num_lanes = len(eye_data_per_lane.keys()) for i, lane in enumerate(eye_data_per_lane): @@ -22,7 +23,7 @@ y1 = eye_data_per_lane[lane]["y1"] y2 = eye_data_per_lane[lane]["y2"] - plt.subplot(int(num_lanes / 2), 2, int(i) + 1) + ax1 = plt.subplot(int(num_lanes / 2), 2, int(i) + 1) plt.scatter(x, y1, marker="+", color="blue") plt.scatter(x, y2, marker="+", color="red") plt.xlim(eye_data_per_lane[lane]["graph_helpers"]["xlim"]) @@ -37,5 +38,15 @@ plt.axvline(0, color="black") # vertical plt.axhline(0, color="black") # horizontal plt.grid(True) + # Add secondary x-axis + x_norm = [round(n * 0.1, 2) for n in range(11)] + x.sort() + x = np.linspace(min(x), max(x), 11) + + ax2 = ax1.twiny() + ax2.set_xlim(ax1.get_xlim()) + ax2.set_xticks(x) + ax2.set_xticklabels(x_norm) + ax2.set_xlabel("Unit Interval (UI)") plt.show()