From c257f016d4037c9ade4723cdbe7939d9bccb0ea7 Mon Sep 17 00:00:00 2001 From: WorldTeacher <41587052+WorldTeacher@users.noreply.github.com> Date: Thu, 8 Feb 2024 15:56:35 +0100 Subject: [PATCH] Update x-axis labels to be slanted --- src/ui/widgets/graph.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/ui/widgets/graph.py b/src/ui/widgets/graph.py index 75cc60c..5c96025 100644 --- a/src/ui/widgets/graph.py +++ b/src/ui/widgets/graph.py @@ -25,6 +25,8 @@ class GraphWidget(QtWidgets.QWidget): self.toolbar = NavigationToolbar(self.graph, self) # set legend self.graph.axes.legend(legend_labels, loc="upper left") + #set x-axis text to be slanted + self.graph.axes.set_xticklabels(data["x"], rotation=45, ha="right") # set the layout layout = QtWidgets.QVBoxLayout() layout.addWidget(self.toolbar) @@ -40,7 +42,7 @@ if __name__ == "__main__": app = QtWidgets.QApplication(sys.argv) data = { - "x": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], + "x": ["A1", "A2", "A3", "A4", "A5", "A6", "A7", "A8", "A9", "A10"], "y": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], "y2": [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], }