Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Qt 3D scatter graph: how can I adjust the scale of an axis?

Tags:

c++

qt

I'm currently developing a Qt desktop application using the Q3DScatter class. I'm inspecting Qt's 3D Scatter example project and I tried to modify the data item set to plot my own data. The data is plotted except that one axis is not well scaled and my 3D plot looks really messy. I'm looking for a way to adjust this axis. I've tried to change the range and the segment count of the axis, I even tried to set the "AutoAdjustRange" of the axis to true, but nothing seemed to solve the problem.

Would really appreciate some help.

PS: Here's a screen capture of what my 3D scatter graph looks like (the "messy" axis is shown with the red arrow)

enter image description here

like image 650
Reda94 Avatar asked Sep 04 '25 16:09

Reda94


2 Answers

Subclassing QValue3DAxisFormatter will not work: it determines where ticks and labels are placed, but not how large the axex actually are.

To do that, you can set the (horizontal) aspect ratio, that is a property of Q3DScatter. The following settings will make the data into a cube volume:

plot->setAspectRatio(1.0);
plot->setHorizontalAspectRatio(1.0);
like image 77
AkiRoss Avatar answered Sep 07 '25 08:09

AkiRoss


I figured this out by creating a CustomFormatter class by subclassing QValue3DAxisFormatter and reimplementing some of its functions (I followed this tutorial). Then I set up my axis formatter to my custom formatter (m_graph->axisZ()->setFormatter(cf);).

like image 33
Reda94 Avatar answered Sep 07 '25 09:09

Reda94