如何在 Qt5 QChart 中将 x 轴设置为从 0 开始

How to set x-axis to start at 0 in a Qt5 QChart

我有一个 y 轴从 -25 到 25 的 QChart。目前我的 x 轴设置在底部(在本例中为 y = -25)。如何设置 x 轴从 y=0 开始?谢谢。

据我所知,像这样排列一个轴是不可能直接实现的。文档说:"Multiple axes can be defined for one chart. The axes can be placed down, up, left, or right of the chart. Further, the axes can be of different types. However, mixing axis types that would result in different domains is not supported, such as specifying QValueAxis and QLogValueAxis on the same orientation."

您可以通过添加 QLineSeries 然后自己绘制标记来模拟中心轴。