Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

qt chart equal axis (axis should form square not rectangle)

How can I set my axis to be equally long in my QChart plot? I want to have my axis to form a square instead of a rectangle so that my contents are not distorted.

I want to change the left example image to look like the right. The axis should have equal length.

example

like image 378
user7431005 Avatar asked Feb 15 '26 00:02

user7431005


1 Answers

Ok, there are two different approaches. Based on how you painted your images, I think the scales have already the same range, so you have to change the layout of the QChartView (the widget which holds the QChart). Do this by using the usual setters like: 'setMinimumSize(width, height)' and 'setMaximumSize(width, height)'.

If you want to achieve the same scale, then set on QAxis 'setRange(min, max)' with min any max being the computed minimum of (xMin, yMin) and 'max = std::max(xMax, yMax)'.

like image 154
Marcel Petrick Avatar answered Feb 16 '26 14:02

Marcel Petrick



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!