Update x-axis labels to be slanted

This commit is contained in:
WorldTeacher
2024-02-08 15:56:35 +01:00
parent 6743c96a5c
commit c257f016d4

View File

@@ -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],
}