From f28e1c45863876d9f861d7a52b4e4b84c921ec53 Mon Sep 17 00:00:00 2001
From: Pierre-Antoine Rouby <pierre-antoine.rouby@inrae.fr>
Date: Wed, 7 Jun 2023 16:04:01 +0200
Subject: [PATCH] Geometry: Plot: Fix x axes.

---
 src/View/Geometry/PlotKPC.py | 4 ++++
 src/View/Geometry/PlotXY.py  | 7 ++++++-
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/src/View/Geometry/PlotKPC.py b/src/View/Geometry/PlotKPC.py
index 1bdd98a3..d48381c4 100644
--- a/src/View/Geometry/PlotKPC.py
+++ b/src/View/Geometry/PlotKPC.py
@@ -52,6 +52,10 @@ class PlotKPC(APlot):
         z_min = self.data.get_z_min()
         z_max = self.data.get_z_max()
 
+        self.canvas.axes.set_xlim(
+            left = min(kp), right = max(kp)
+        )
+
         self.line_kp_zmin_zmax = self.canvas.axes.vlines(
             x=kp,
             ymin=z_min, ymax=z_max,
diff --git a/src/View/Geometry/PlotXY.py b/src/View/Geometry/PlotXY.py
index 89492bf4..a64afbe5 100644
--- a/src/View/Geometry/PlotXY.py
+++ b/src/View/Geometry/PlotXY.py
@@ -52,6 +52,11 @@ class PlotXY(APlot):
             color='green', fontsize=12
         )
 
+        kp = self.data.get_kp()
+        self.canvas.axes.set_xlim(
+            left = min(kp), right = max(kp)
+        )
+
         # Draw line for each profile
         self.line_xy = [
             self.canvas.axes.plot(
@@ -61,7 +66,7 @@ class PlotXY(APlot):
             )
             for x, y, kp in zip(
                     self.data.get_x(), self.data.get_y(),
-                    self.data.get_kp()
+                    kp
             )
         ]
 
-- 
GitLab